Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-10-2008, 10:29 PM   #1
LQ Newbie
Registered: Feb 2008
Posts: 2

Rep: Reputation: 0
executing startup script on shared server (not as root!)

Hi All,

I have a website hosted by successfulhosting on a Redhat system (i think!):
-sh-3.00$ cat redhat-release
CentOS release 4.5 (Final)
Everything is working great, but I want to execute a little shell script that kicks off a php script that polls the mailbox, and scrapes new mail into a database. The script is written, and works fine, but I want it to autostart after a reboot so that it's always running.

I've looked around for ages on the web about where to put startup scripts, and they all seem to say add it to rc.local or /etc/init.d or something.

Everything not in my home directory is owned by root, though, so how do I do this? I can ssh in fine, but don't know what to do from there..

Thanks for any help - I'm slowly learning about linux, but it seems a very steep learning curve!


Old 02-10-2008, 11:08 PM   #2
Senior Member
Registered: Oct 2003
Posts: 2,559

Rep: Reputation: 213Reputation: 213Reputation: 213
Put the script in your home directory and make sure it's executable. Then edit your /home/<username>/.bashrc file by adding the following line at the end:


Every time you login, your script should run with username privileges.
Old 02-10-2008, 11:10 PM   #3
Senior Member
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,125

Rep: Reputation: 165Reputation: 165
You can modify stuff in /etc/init.d as root or by using su or sudo. To add an entry that runs as another user you could add something like this (changing your username and script name):
/bin/su - username -c /path/to/your/script.php
Old 02-11-2008, 01:42 AM   #4
LQ Newbie
Registered: Feb 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Thumbs up Problem solved

Hi guys,

thanks for the replies..

kilgoretrout: I found the .bashrc file, made it executable, and ran it successfully. I guess I'll have to wait until the server reboots before knowing for sure, but it seems great so far, thanks..

gilead: thanks for the reply - but to log in as root (or change root's script to log in as me), i would need root's password, right? I'm just one of fifty hiring space on this server - they definitely didn't give me root access..!

very much appreciate the quick answers - thanks guys..



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Python script as root at startup StuL Linux - General 2 03-05-2008 05:33 PM
Executing a script when uploading a file to a SAMBA SERVER rafa_gallego Linux - Server 4 01-18-2008 05:39 AM
How do I run a startup script as a user other than root? Questor21 Linux - Software 4 04-08-2006 11:51 AM
Lauching script at shell startup without having root access. begin55676 Linux - Newbie 2 12-10-2004 03:42 PM
executing script via webpage through apache server feetyouwell Linux - Software 7 02-08-2004 03:23 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:08 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration