Re: cron jobs not done during sleep



On Mon, Sep 17, 2007 at 08:22:45AM -0700, Steve Franks wrote:
Correct me if I'm wrong, but cron doesn't keep track of the last time
something was done, does it? Which is to say if my system is crashed,
was asleep, or powered off when a job is supposed to happen, it will
not happen the next time the system is successfully operational, will
it? It's not obvious to me for sure either way from any sources I've
read (man crontab, google), and unix tends towards k.i.s.s. (which is
why we like it)

...I understand why that would be important behavior if something
would cause problems executed other than 9am on Mondays...

Is there a tool or setting to implement this functionality? I want
something to happen weekly, I don't care when. Assume I am off the
commercial power grid and I'm not going to leave my system powered on
just to make sure my backups get run. I use it when I need it, then I
turn it off. More people should. Electricity is not free from a
economic, social, or environmental perspective, and promises to be
less so with time.

Is easy enough to implement yourself. Write a script containing your
weekly commands. Launch it every hour or so.

First thing in your script look for a flag file indicating last time
your script was run. If it does not exist, create it (suggest using
touch), and run the rest of your script.

If the flag file does exist compare dates. If older than some specified
interval then touch(1) it and run the rest of your script. Might get
fancy and code the date test in the crontab command field.

/var/run might be a good place to put your flag file.

Notice the test(1) utility can compare new/older file dates and that
touch(1) can stamp a future date on the file.

You can compile a future date with "date -v +1W". Play with the
formatting options to make the output compatible with input to touch.

--
David Kelly N4HHE, dkelly@xxxxxxxxxx
========================================================================
Whom computers would destroy, they must first drive mad.
_______________________________________________
freebsd-questions@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: Newbie to logon scripts - how to make a script run once only?
    ... script can check for the existence. ... The logon script would check for the existence of the flag file. ... nature of the flag file depends on the deployment. ...
    (microsoft.public.windows.server.scripting)
  • Re: [SLE] Pullin my hair out... arrrgh
    ... > story of the donkey that needed a 2x4 in the head to get its attention so it ... Alternatively, what the original poster said, is to have the script run ... Ie, the first time it would run at 00:00 hours, and would save a flag file ... the flag file, notice the time lapse not being 18 hours, ant exit. ...
    (SuSE)
  • Re: Application to be called - runas Administrator
    ... you can run the script through MS script encoder, ... >I don't believe you can compile a vbscript - this information was passed on ... This flag file would be checked for presence in the ... >> beginning of the compiled program to bypass if it had already been run on ...
    (microsoft.public.scripting.vbscript)
  • Re: [SLE] cron.daily
    ... > The main script gets run every 15 minutes. ... NO math is performed, cron runs when instructed. ... > This ensures that each flag file is deleted, if the machine is running at ... boot your machine at 8:10 run-crons will still run at 8:15 -not- at ...
    (SuSE)
  • Re: [Full-Disclosure] Cleanining viruses from netware
    ... Another approach is to use a login script that runs the disinfection ... run, run the script and then *IF* successful, create the flag file. ... infected machines and remove them. ...
    (Full-Disclosure)