Gentoo Archives: gentoo-user

From: Alan McKinnon <alan.mckinnon@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Script to tar.tgz /etc, works run manually, broken when run from cron
Date: Mon, 31 Mar 2014 14:58:06
Message-Id: 53398255.1080607@gmail.com
In Reply to: [gentoo-user] Script to tar.tgz /etc, works run manually, broken when run from cron by Tanstaafl
1 On 31/03/2014 13:01, Tanstaafl wrote:
2 > Hi all,
3 >
4 > Ok, this is really irritating me...
5 >
6 > I have a script that simply performs some backups. The commands are like
7 > this:
8 >
9 > # perform tar.tgz backup of /etc
10 > tar -czpvf $BKUP_DIR_etc/$BKUP_DateTime-dev-ecat-etc.tgz /etc
11 >
12 > When I run this script manually, it does what it is supposed to, and the
13 > resulting file is about 500K.
14 >
15 > When it runs from cron (roots crontab), it results in a 20 byte (empty)
16 > file.
17 >
18 > So what am I missing/doing wrong?
19 >
20 >
21
22 It's almost always the same two things that cause this:
23
24 1. cron doesn't give you an environment so there's no $PATH. Other
25 posters covered this nicely.
26
27 2. I had this one just last week in fact - pwd is not what you think it
28 is. In cron it ends up being / so the solution was again to use full
29 paths. In my case, I had a config file listed on the command line.
30
31
32
33 --
34 Alan McKinnon
35 alan.mckinnon@×××××.com