Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
flexbackup not running under cron? [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
NotExcessive
Apprentice
Apprentice


Joined: 10 May 2005
Posts: 235

PostPosted: Sun Jul 16, 2006 8:12 am    Post subject: flexbackup not running under cron? [SOLVED] Reply with quote

I've installed flexbackup and want to have it do automated backups under vixie-cron. Everything works when done manually, and I've added an entry to the crontab file to perform an incremental backup every hour.

This is what I have in /var/spool/cron/crontabs/root:

Code:
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.XXXXt9Wqwc installed on Sat Jul 15 13:00:54 2006)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
0 2 * * * updatedb #Update db for slocate
@hourly flexbackup -set all -incremental #Incremental backup of system to tape
0 6 * * * emerge --sync


Problem is, when the hour approaches, nothing happens. The entries get put into the log file, so it looks as if cron is issuing the command, but the tape drive sits idle.

This is what I see in /var/log/everything/current:
Code:
Jul 16 15:00:01 [cron] (root) CMD (rm -f /var/spool/cron/lastrun/cron.hourly)
Jul 16 15:00:01 [cron] (root) CMD (flexbackup -set all -incremental #Incremental backup of system to tape)


I see this repeated every hour on the hour. If I look at it from Webmin -> System -> Scheduled Cron Jobs and hit the "run now" button, the tape backs up, as it should.

Can anyone tell me why the job's not running?


Last edited by NotExcessive on Tue Jul 18, 2006 2:27 pm; edited 2 times in total
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2977
Location: Germany

PostPosted: Sun Jul 16, 2006 8:28 am    Post subject: Reply with quote

The # comment should probably not be on the same line as the cron job itself.

Instead of executing flexbackup directly, try wrapping it in a shell script and redirect all output into a >& /tmp/flexbackup.log file. Then you'll know wether the script gets executed at all (logfile exists or not), and what went wrong (according to output).
Back to top
View user's profile Send private message
NotExcessive
Apprentice
Apprentice


Joined: 10 May 2005
Posts: 235

PostPosted: Sun Jul 16, 2006 9:38 am    Post subject: Reply with quote

Ah. Creating a file /root/backinc with the following contents:

Code:
#!/bin/bash
flexbackup -set all -increment > flexbackup_output.log


and then chmod+x backinc

resulted in the following being put into flexbackup_output.log when run from vixie-cron:

Code:
Errors:
  mt not found in $PATH



Yet I can cd into any directory and run /root/backinc from the command line without a problem - no errors at all. What's happening? The contents of /etc/crontab are
Code:
# for vixie cron
#
# $Header: /var/cvsroot/gentoo-x86/sys-process/vixie-cron/files/crontab-3.0.1-r4,v 1.1 2005/03/04 23:59:48 ciaranm Exp $
#
#

# Global variables
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly
0  *  * * *   root   rm -f /var/spool/cron/lastrun/cron.hourly
1  3  * * *   root   rm -f /var/spool/cron/lastrun/cron.daily
15 4  * * 6   root   rm -f /var/spool/cron/lastrun/cron.weekly
30 5  1 * *   root   rm -f /var/spool/cron/lastrun/cron.monthly
*/10  *  * * *   root   test -x /usr/sbin/run-crons && /usr/sbin/run-crons


so $PATH includes /usr/sbin, which is where the mt utility lives.

Why is cron dropping the path to mt?
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2977
Location: Germany

PostPosted: Sun Jul 16, 2006 11:50 am    Post subject: Reply with quote

I suggest you print the env variables out in the shellscript... to verify wether PATH is actually set correctly; also if it is, check the returnvalue of `which mt`. It should be found if it is in the path.
Back to top
View user's profile Send private message
NotExcessive
Apprentice
Apprentice


Joined: 10 May 2005
Posts: 235

PostPosted: Sun Jul 16, 2006 1:38 pm    Post subject: Reply with quote

Running env > showvars.txt and inspecting showvars.txt reveals
Code:
DOCUMENT_REALROOT=/usr/libexec/webmin
SHELL=/bin/sh
PATH_REALTRANSLATED=/usr/libexec/webmin/
USER=root
LD_LIBRARY_PATH=
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/sbin:/usr/sbin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
SERVER_REALROOT=/usr/libexec/webmin
PWD=/usr/libexec/webmin/cron/
REMOTE_ADDR=127.0.0.1
SHLVL=1
HOME=/root
LOGNAME=root


when run from the command line, BUT shows
Code:
SHELL=/bin/sh
USER=root
PATH=/usr/bin:/bin
PWD=/root
SHLVL=1
HOME=/root
LOGNAME=root
_=/usr/bin/env

when run from vixie-cron itself.

and which returns
Code:
/usr/sbin/mt
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2977
Location: Germany

PostPosted: Sun Jul 16, 2006 2:44 pm    Post subject: Reply with quote

Hmmm, so even though it is run as user root, the environment variables look like those of a normal user (no sbin in path).

I just tested this on my own machine; it's actually the same for me. No idea why these paths are not set. Maybe a search on the forums or in the bugtracker will reveal prior discussions to this.

Workaround: change PATH variable inside the shell script.
Back to top
View user's profile Send private message
NotExcessive
Apprentice
Apprentice


Joined: 10 May 2005
Posts: 235

PostPosted: Mon Jul 17, 2006 12:11 am    Post subject: Reply with quote

This seems to be the only thing to do. I've created a file /root/incremental_backup.sh:

Code:
#!/bin/bash
PATH=/usr/bin:/bin:/usr/sbin
flexbackup -set all -incremental


And just put it into /var/spool/cron/crontabs/root:
Code:
@hourly /root/incremental_backup.sh


And that's that. I just wonder, do I need to modify the file to output to /dev/null at all? flexbackup generates text output as to what it's done. It all works, just curious.
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2977
Location: Germany

PostPosted: Mon Jul 17, 2006 7:00 am    Post subject: Reply with quote

Most cron will send you mails if the programs produce output (especially stderr output) to make you aware of errors. I'm not sure about vixie-cron though.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum