3

I want to run a thing that may disrupt the system (or remote access to it) if something goes wrong (for example, misconfiguration).

To reduce problems I want to have a "grace period" after the system already started, but before "dangerous" service started.

Requirements:

  1. Delay is applied only on automatic starting of the initscript, not when I /etc/init.d/whatever start manually;
  2. The script is not started until its dependencies are ready (according to usual rules in initscript headers);
  3. Boot process should go on, without waiting for the full timeout.

How to do it more or less cleanly?

Related: https://superuser.com/questions/460112/how-do-i-run-a-script-5mn-after-startup

4

"More or less cleanly" is my second name. Use the @reboot function in /etc/crontab as I show it here. Will be a line in /etc/crontab like

@reboot root (sleep 3600; /etc/init.d/whatever start) &

and of course update-rc.d disable whatever.

3
  • 1
    wait 3600 should be sleep 3600 ? – Olivier Dulac Jan 22 '14 at 16:32
  • How will it protect from early start in case of boot sequence takes longer than usual? I.e. cron is started, then some dependency takes very long to start (more than 3600), then whatever being started out-of-order by cron. – Vi. Jan 22 '14 at 16:33
  • @Vi: "whatever" should then veriry&wait until "this" and "that" happened. But it will only have to wait after that first sleep (here, sleep 3600 which is 1 hour) ... And can wait also by using a while ( not_this_and_that_yet ) ; do sleep 60 ; done (for example). using sleep allow the kernel to just put the script "on the side" until the next wake period – Olivier Dulac Jan 22 '14 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.