When does crontab starts?

1

I'm having lots of problems with my Ubuntu 10.04 in AWS and init scripts. I have my rc.local with some mounts, mkdirs & more but they don't do everything as expected, just a few of them and not always the same.

I'm learning puppet, but until I'll be prepared to get my machine remotely configured I'm trying to do something more ugly. I thought to do a cronjob every 3 minutes to configure all the system and save a flag file in my /dev/shm. When my instance get rebooted or something worse, this file will be deleted and my script will attempt to init the server again.

Do you have something more clever?

Thanks in advance!

enedebe

Posted 2012-08-22T13:41:02.237

Reputation: 133

1Why do you have mounts and mkdirs in rc.local scripts? What does "capture the system" mean? Please edit your question to make it more specific. What exactly are you trying to do? I get the impression you are making things much more complicated than necessary. – terdon – 2012-08-22T14:00:07.883

Answers

1

You don't need to mess with flag files – cron already does that for you. You can schedule a @reboot job which will be run exactly once every time the instance starts:

In a user crontab:

@reboot /my/script

In a system-wide /etc/crontab:

@reboot root /my/script

And of course, simply adding commands to /etc/rc.local will have the same effect, since rc.local is only run when booting (though a little later than @reboot cronjobs).

user1686

Posted 2012-08-22T13:41:02.237

Reputation: 283 655

Side note: /dev/shm is the wrong location for flag files; it is used by Linux glibc shm functions. Most programs use the directories /run (FHS 3.0 d1) or /var/run (FHS 2.3) to store runtime data.

– user1686 – 2012-08-22T15:04:42.380