Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

daemon process and login via script

Status
Not open for further replies.

itsnammu

Programmer
Oct 16, 2003
14
0
0
IN
i want to write a script which will start automatically at whenthe system boots and will run in the daemon mode continously, please suggest.
in this script i want to login to a particular user and want to perform some task.

please suggest how should i start a daemon at system startup and then from a script login to a diffrent user, i have access to the password
 
I am not quite sure what you mean by daemon mode, or do you mean to run in the background?

#!/bin/sh

su - USER -c "command &
 
To start a script during system initialization, you can put the script in /etc/rc3.d. The name of the script must start with a captial "S". If you put the script in /etc/rc3.d, the system will start your process during initialization to run level 3. Depending on what your script is doing, you may want to write a kill script to kill the process when the system is being shutdown. You would put that script in /etc/rc2.d. The name of the script must start with a captial "K".
 
Have a look at some of the scripts in rc3.d They should give you an idea of the 'standard' way of doing this.
 

I agree with "coffeysm"'s suggestion:

only add a "nohup" to keep it running in background.
eg:
#!/bin/ksh
su - USER -c "cd /dir; nohup ./command &"

Hope this will help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top