aconsuegra2
January 9th, 2014, 09:17 PM
I am configuring a backup in ubuntu server.
It consists in a second server, powered by POE (etherwake command) in the backup script.
When i execute the script, as root in a ssh shell session, the backup server is powered on as expected, but if i program a job in crontab, the etherwake commnad does nor power up backup server.
Everithing in the backup script works just as expected, except the etherwake command.
If i execute the etherwake command in another ssh session, the backup ends ok.
The crontab job is added in the root account (executed as root)
Relevant parts of script home-sync.sh
#!/bin/bash
#
TYPE="sync"
HOST="prodsvr"
LOGFILE="/home/copias/bck$TYPE`date +%y%m%d`.log"
SOURCE="/home/"
DESTDIR="/home/copias/home"
DESTHOST="bcksvr"
DESTPH="00:10:a1:f0:01:c0"
WAIT=1
BCKBOOT=0
echo `date`: Iniciada copia a sistema de respaldo > $LOGFILE
while [ $WAIT -le 15 ]
do
PING=$(ping -c 1 $DESTHOST 2>&1| grep "% packet" | cut -d" " -f 6 | tr -d "%")
if [ "$PING" = 0 ]
then
echo `date`: $DESTHOST está vivo >> $LOGFILE
WAIT=15
BCKBOOT=1
else
echo `date`: Despertando $DESTHOST pase $WAIT >> $LOGFILE
etherwake $DESTPH
sleep 1m
fi
(( WAIT++ ))
done
.
.
.
And the contab line in root accout:
00 02 * * * /home/copias/home-sync.sh
How is it possible?
It consists in a second server, powered by POE (etherwake command) in the backup script.
When i execute the script, as root in a ssh shell session, the backup server is powered on as expected, but if i program a job in crontab, the etherwake commnad does nor power up backup server.
Everithing in the backup script works just as expected, except the etherwake command.
If i execute the etherwake command in another ssh session, the backup ends ok.
The crontab job is added in the root account (executed as root)
Relevant parts of script home-sync.sh
#!/bin/bash
#
TYPE="sync"
HOST="prodsvr"
LOGFILE="/home/copias/bck$TYPE`date +%y%m%d`.log"
SOURCE="/home/"
DESTDIR="/home/copias/home"
DESTHOST="bcksvr"
DESTPH="00:10:a1:f0:01:c0"
WAIT=1
BCKBOOT=0
echo `date`: Iniciada copia a sistema de respaldo > $LOGFILE
while [ $WAIT -le 15 ]
do
PING=$(ping -c 1 $DESTHOST 2>&1| grep "% packet" | cut -d" " -f 6 | tr -d "%")
if [ "$PING" = 0 ]
then
echo `date`: $DESTHOST está vivo >> $LOGFILE
WAIT=15
BCKBOOT=1
else
echo `date`: Despertando $DESTHOST pase $WAIT >> $LOGFILE
etherwake $DESTPH
sleep 1m
fi
(( WAIT++ ))
done
.
.
.
And the contab line in root accout:
00 02 * * * /home/copias/home-sync.sh
How is it possible?