How would I automate shell script startup during a reboot??
Linux - NewbieThis 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!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How would I automate shell script startup during a reboot??
Greetings,
How would I go about having some shell scripts start up during a reboot of a Linux server? These shell scripts pertain to some applications and must startup with a different user rather than root user.
I was thinking of writing a script and have sysinit start it up during the reboot. However, I am not sure where to start.
3.) make a symbolic link to tell Linux to execute at startup
cd /etc/rc.d/rc3.d " - if your runlevel in runlevel 3
4.) while in /etc/rc.d/rc3.d do - ln -s ../init.d/filename S55FILENAME
that is it
Thank you for the quick respoonse!! I need do something like 'su -u user_name' to execute the the script?? I wouldn't want root to execute this script due to security reason.
Here's the command that I execute manually:
nohup ./agentscheduler.sh -port=9003 -name=THRASHER1_9003 &
nohup ./agent.sh -port=9004 -name=THRASHER1_9004 &
When I run the command above, I had to logged in as 'a_agent' user account to execute it.
if so, I do I incorporate that user in the script??
I have a script in /etc called rc.local where I added a startup command for a test Forum.
The script original had one uncommented line "exit 0" and I added my command just above that.
-----------------------
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/opt/lampp/lampp start
exit 0
-------------------------------------------
Thank you for the quick respoonse!! I need do something like 'su -u user_name' to execute the the script?? I wouldn't want root to execute this script due to security reason.
Here's the command that I execute manually:
nohup ./agentscheduler.sh -port=9003 -name=THRASHER1_9003 &
nohup ./agent.sh -port=9004 -name=THRASHER1_9004 &
When I run the command above, I had to logged in as 'a_agent' user account to execute it.
if so, I do I incorporate that user in the script??
Thank you!!
J
Lol, good question ... I guess you would need to add an authentication section to do that, but would not be great to do , because you will have to store the password in the file ( which is clear text )
Thank you for the quick respoonse!! I need do something like 'su -u user_name' to execute the the script?? I wouldn't want root to execute this script due to security reason.
Here's the command that I execute manually:
nohup ./agentscheduler.sh -port=9003 -name=THRASHER1_9003 &
nohup ./agent.sh -port=9004 -name=THRASHER1_9004 &
When I run the command above, I had to logged in as 'a_agent' user account to execute it.
if so, I do I incorporate that user in the script??
Thank you!!
J
Hi Guys,
Do I put the command "exit 0" after each command line I execute or just once at the end of the script?
Actually you don't need to use it at all.
The default exit status of a shell script is that (ie status) of the last cmd run. You only need to specify it explicitly if you have a wrapper script that checks the exit status.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.