sleeper and rebooter
Florian Diesch
diesch at spamfence.net
Wed Aug 13 08:39:42 UTC 2008
"Oguz Yarimtepe" <comp.ogz at gmail.com> wrote:
> Hi,
>
>>
>> Could you explain what these programs are doing?
>>
>
> Sure. They are the programs that are used to reboot the computer or
> suspend the computer defined number of times automatically. So what
> they do is make the computer go to suspend mode then awake wait and
> repeat the process again. Also for the rebooter.
I don't know any program to do this on Linux. But here's a simple
shell script that may do the job.
Be careful, it's not well tested. Use at your own risk.
--8<---------------cut here---------------start------------->8---
#!/bin/sh
## Directory to store our files
DATA_DIR=/you/need/to/change/this
## Logging goes here
LOGFILE="$DATA_DIR/nrun.log"
## The counter is saved here
COUNTERFILE="$DATA_DIR/nrun.counter"
## Command to run
CMD=gnome-power-cmd.sh suspend
help(){
echo "Usage:"
echo " $0 N"
exit 1
}
if [ $# -lt 1 ]; then
help
fi
N="$1"
if [ -f "$COUNTERFILE" ]; then
COUNT="$(cat "$COUNTERFILE")"
else
COUNT=0
echo > "$LOGFILE" # start new logfile
fi
COUNT="$((COUNT+1))"
if [ "$COUNT" -gt "$N" ]; then
echo > "$COUNTERFILE"
exit 0
fi
echo "$CMD: $COUNT of $N at $(date)" >> $LOGFILE
echo "$COUNT" > "$COUNTERFILE"
$CMD
--8<---------------cut here---------------end--------------->8---
Adapt the first few lines to your needs (gnome-power-cmd.sh requires
GNOME to be running, instead of suspend you may use shutdown,
hibernate or reboot) and call the script, e.g.
/the/dir/you/saved/nrun 10
from /etc/rc.local or a user's session (in this case you should
configure gdm (or whatever display manager you are using) to login
that user automatically).
Florian
--
<http://www.florian-diesch.de/>
-----------------------------------------------------------------------
** Hi! I'm a signature virus! Copy me into your signature, please! **
-----------------------------------------------------------------------
More information about the ubuntu-users
mailing list