using crontab to run scripts at boot
Hey all-
I'm trying to hook a couple of scripts into the boot sequence of my ubuntu hardy machine. I entered the following line into the crontab Code:
@reboot bash ~/monitor.sh Cheers, Jarrod |
I think the proper place to put scripts for boot is in the init scripts. I think Ubuntu now uses the Upstart system, it used to use files in /etc/init.d. Not sure at what point that migration occurred, but those are your two best options.
|
You can put your script in /etc/rc.local
|
I've never seen that syntax for a crontab before - where did you find that? :}
The "normal" way to do what you're trying to achieve would be to put the script into /etc/init.d and make an appropriate symlink in rc1.d |
I found that particular crontab syntax here:
http://www.debianhelp.co.uk/crontab.htm It seems like it would be pretty handy for things you want to run weekly, monthly, etc. I'm trying out the init.d/rc1.d symlink setup for now. Hopefully this will be a bit more stable. On a different note, I have an opinion question: The monitor script waits until another script (we'll call it configure.sh) arrives from a remote machine, and then runs it. Configure.sh then runs the two actual business scripts that I need. Does that sound like a reasonable method or is there a better way than daisy-chaining scripts like that? EDIT: Hm. putting the monitor.sh script in /etc/init.d and creating a symlink to it called Smonitor in rc1.d doesn't seem to be working. I don't think it's running at all. Granted, I'm not sure, because I'm booting up a remote machine here, but since none of the output directories are getting created I think monitor.sh isn't getting executed on reboot. Do I need to change my script to accept a "start" argument like it says in the Debian policy manual? |
Interesting ... which version the vixie cron is that?
The dillon one that comes with Slack 12.2 doesn't have the feature. Cheers, Tink |
Tink-
It appears that it's the 4th Berkeley Distribution, dated 31 October 2006. I can't find a specific version though. I have a bit of an different question for you- remember this while loop condition you gave me a month or so ago? Code:
while $( ec2din --simple | awk 'BEGIN{flag=0}{if($0 ~ /pending/){flag++}}END{if ( flag > 0 ) {exit 0} else {exit 1}}' ); Code:
while $( find $PWD -name configure.sh | awk 'BEGIN{flag=0}{if($0 ~ /"/root/configure.sh"/){flag++}}END{if ( flag = 0 ) {exit 0} else {exit 1}}' ); |
Two things with that:
a) strip the quotes. Escape the /'s with backslash: Code:
/\/root\/configure.sh/ Code:
flag == 0 Code:
flag =0 Cheers, Tink |
All times are GMT -5. The time now is 11:31 AM. |