Attn "Bit Twister" was Re: cron poweroff script. do test it - Mandriva
This is a discussion on Attn "Bit Twister" was Re: cron poweroff script. do test it - Mandriva ; On Wed, 21 Nov 2007 06:37:25 -0500, Bit Twister wrote:
Please send me your email address
Initial comments, without yet having tested the script.
Minor item. In the comments, hour is listed as 0-13, instead of 0-23. Note that
in ...
-
Attn "Bit Twister" was Re: cron poweroff script. do test it
On Wed, 21 Nov 2007 06:37:25 -0500, Bit Twister wrote:
Please send me your email address 
Initial comments, without yet having tested the script.
Minor item. In the comments, hour is listed as 0-13, instead of 0-23. Note that
in a day with a leap second, it can hit 24, I think. 
Another Minor item - The order of execution by run-parts, is based on the lexical
(alphabetical) sorting of the script names, not the order the files occur in
the directory. Compare /bin/ls -l /etc/cron.daily with /bin/ls -lU /etc/cron.daily.
A simpler approach, in my opinion, would be a single script in cron.d that parses
/etc/crontab, figures out whether any other crontab entries are going to be run, and
when they are, wait until after they should have started, and then wait until
there's only one run-parts running (which would be cron.daily), before running
the poweroff. It think it would also be good to cancel the auto poweroff, if
there are any terminal users logged in.
Regards, Dave Hodgins
--
Change nomail.afraid.org to ody.ca to reply by email.
(nomail.afraid.org has been set up specifically for
use in usenet. Feel free to use it yourself.)
-
Re: Attn "Bit Twister" was Re: cron poweroff script. do test it
On Thu, 22 Nov 2007 12:44:33 -0500, David W. Hodgins wrote:
> Minor item. In the comments, hour is listed as 0-13, instead of 0-23.
Frap, spelling checker missed that one. 
> Note that in a day with a leap second, it can hit 24, I think. 
Hm, I would have guessed seconds would hit 60 instead, :-P
> Another Minor item - The order of execution by run-parts, is based
> on the lexical (alphabetical) sorting of the script names, not the
> order the files occur in the directory. Compare /bin/ls -l
> /etc/cron.daily with /bin/ls -lU /etc/cron.daily.
OK, comment changed to
#*
#* run-parts will run scripts in the lexical sort order of the filenames in
#* indicated directory. To see which order scripts are executed without
#* running them, do something like run-parts --test $HOME/tmp/cron.daily
#*
> A simpler approach, in my opinion, would be a single script in
> cron.d that parses /etc/crontab,
Hmmm, that would execute every minute. Hope it gets done before
the next minute rolls around.
> figures out whether any other crontab entries are going to be run,
True, might not hurt to roam through any files in /var/spool/cron and
/etc/cron.d and also check if any of those files have something like
I found in release 2007.0/1
#!/bin/bash
# /etc/cron.d/php: crontab fragment for php
# This purges session files older than X, where X is defined in seconds
# as the largest value of session.gc_maxlifetime from all your php.ini
# files, or 24 minutes if not defined. See /usr/lib/php/maxlifetime
# Look for and purge old sessions every 30 minutes
09,39 * * * * root [ -d /var/lib/php ] && \
find /var/lib/php/ -type f -mmin +$(/usr/lib/php/maxlifetime) \
-print0 | xargs -r -0 rm
> and when they are, wait until after they should have started, and
> then wait until there's only one run-parts running
^
|
"Minor item." ------------------' should read none since you seemed
to have moved the script to /etc/cron.d 
> (which would be cron.daily), before running the poweroff.
Only if you moved the script from /etc/cron.d back to /etc/cron.daily 
> It think it would also be good to cancel the auto poweroff,
> if there are any terminal users logged in.
Might not hurt to check if any user is running anything be it
at, cron or terminal not to mention those pesky zombies. 
Then there is off chance user hit Ctl+Alt+F2, logged in, Ctl+Alt+F7
and forgets about that log in. 
I wrote the script for you to play with, feel free to hack away.
I had forgot to set the DEBUG flag, and it powered down my system so I
know poweroff works on my system.
-