> i use cron and every night at 4:02 it run the poweroff command, and this
> is ok and working.
> Sometimes, when i am in another room on another PC im watching divx stored
> on a samba share on linux and magic,
> if im watching it at 4:00 cron turn off linux and i must go poweron it,
> how can i test something or can i block cron from executing the scripts if
> there is samba working?
There are multiple ways to go about it, but i think the first thing you need
to do is not call poweroff directly, but make a wrapper script. In this
wrapper you can do something like:
pgrep -f mbd || /sbin/poweroff
All that does is looks to see if nmbd/smbd are running, and runs poweroff if
If you want to get trickier you could parse the output from smbstatus and
see if any files are open. (man smbstatus)
Another option is to test the system load:
uptime | perl -ne '$_=~/(\S+), \S+, \S+$/;print $1;'
Will print out the current system load, so you could do some operation on it
(e.g., see if it's >0.1, and don't poweroff if it is). Because of the
comparison of a floating-point number, that'll probably be much easier if
you'll write your wrapper in perl, instead of as a shell script.
----- stephan beal
Registered Linux User #71917 http://counter.li.org
I speak for myself, not my employer. Contents may
be hot. Slippery when wet. Reading disclaimers makes
you go blind. Writing them is worse. You have been Warned.