LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Load .sh file on Linux Ubuntu startup (https://www.linuxquestions.org/questions/linux-server-73/load-sh-file-on-linux-ubuntu-startup-610282/)

Fired501 12-31-2007 11:01 PM

Load .sh file on Linux Ubuntu startup
 
Hey guys,
I wanted to do this a long time ago, but I guess I just forgot. But now when it's 6 AM and I have to wait until my server will reboot - Well, kind of annoying....
So. I have a .sh file, which contains Shell commands. I basically created one, so when server starts up, I wouldn't have to type all commands my self, but just type ./startup.sh and everything would ok.
So. I'm accessing my server ( Ubuntu 6.10 ) through PuTTy, and I Was wondering - if there is a chance, to add the startup.sh file to Autostart.

Thank you.

thedonkdonk 01-01-2008 04:14 AM

Not sure what you mean by "autostart" but if you want a bash script to run at login then you can put it in your ~/.bash_profile file. Or if you need it for all users then in /etc/profile file. If you have questions about this just ask.

Thanks,
James Glenn
www.thedonkdonk.net

Deleriux 01-01-2008 04:30 AM

If you mean on system startup there are two easy ways I can think of off of the top of my head.

a) Add a call to the file in the file to /etc/rc.local
b) Call the file as a cronjob by using the command "crontab -e" and the "time" of @reboot .

I.E
Code:

[user@localhost ~]$ sudo crontab -e
0  0  *  *  *    sh /usr/loca/bin/someotherscript.sh
@reboot            sh /usr/local/bin/myscript.sh


reddazz 01-01-2008 05:09 AM

This article will help you achieve your goals. Basically you need to copy startup.sh to /etc/init.d and rename it to startup. After that do "update-rc.d startup defaults" so that its automatically run at boot up.


All times are GMT -5. The time now is 06:13 PM.