Is there any way to make/run a bash script on reboot (like in Debian/Ubuntu for instance, since thats what my 2 boxes at home have)
Also, any recommended guides for doing cron jobs? I'm completely new to them (but they will be of great use)
migrated from serverfault.com Feb 21 '11 at 20:46
This question came from our site for system and network administrators.
On Ubuntu/Debian/Centos you can set up a cron job to run @reboot. This runs once at system startup. Use crontab -e to edit the crontab and add a line like the example below e.g.
There are lots of resources for cron if you look for them. This site has several good examples.
Another typical way to start something at boot on many *nix platforms is (or was, I think this may be starting to loose favor -- see alternatives) to put scripts in a directory which, depending on the particular OS/distribution, might be something like
In the above style, scripts in, e.g.,
The files in
Various utilities exist on various systems to manage these, as well, turning things on and off, etc. On IRIX (since IRIX 4, at least, if my memory serves), it used to be a tool called
On an Ubuntu 9.04 system I have access to, it looks like
If you're on a system that uses inittab, you can also add things directly there -- which can be especially useful for things that you want to run not just once at boot, but to have actively monitored (by
the @reboot section in crontob is new to me, but also seems like it might be a useful option -- though I would suggest init scripts as being preferable for many things. But see
I hope that's helpful.