Discussion:
troubles with tar, compression and cron
(too old to reply)
Jukka Salmi
2003-12-10 14:50:22 UTC
Permalink
Hi,

I wrote a script which uses tar to backup a filesystem to a Seagate DAT.
If I run the script from the shell it works fine, but when started by cron
(as root) I get this:

tar (grandchild): gzip: Cannot exec: No such file or directory
tar (grandchild): Error is not recoverable: exiting now
/dev/nst0: Device or resource busy

The command which causes this error is 'tar -czf /dev/nst0 ...'. The same
error happenes if I use bzip2 (tar -j). Not using compression at all solves
the problem, but I'd really like to store the data compressed...

Any hints?


TIA, Jukka
--
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~
--
To UNSUBSCRIBE, email to debian-user-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Christian Schnobrich
2003-12-10 15:50:12 UTC
Permalink
Post by Jukka Salmi
The command which causes this error is 'tar -czf /dev/nst0 ...'. The same
error happenes if I use bzip2 (tar -j). Not using compression at all solves
Just a wild guess... try to omit the dash, like 'tar cfz /dev/...'

I have on several occasions created files named 'z','v', or 'j'.
It was always the last letter of the options, that wasn't taken as
option but as the output filename. The 'works-for-me' solution was to
omit the dash. Tar doesn't need it, but I usually put it there anyway
because I'm used to options being preceded by a dash.

If this is happening to you, tar wants to create a file named 'z', and
reads first from /dev/nst0 where it doesn't find anything and spills out
an error.

cu,
Schnobs
--
To UNSUBSCRIBE, email to debian-user-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Jukka Salmi
2003-12-11 12:20:15 UTC
Permalink
Hello,

I still couldn't solve my problem. I stripped down the script to the
following:

$ cat ~/bin/tapetest
#!/bin/sh
cd /
/bin/tar -czf /dev/nst0 dir
echo "tar returned $?"

Running it manually gives:

$ ~/bin/tapetest
tar returned 0

...but when run from cron I get:

tar (grandchild): gzip: Cannot exec: No such file or directory
tar (grandchild): Error is not recoverable: exiting now
tar returned 141

As said before, the same happens if I use bzip2 in place of gzip (except
the above error message from tar is 'bzip2: Cannot exec:', of course...).
Using no compression works fine even with cron...

This is on a Debian testing i386 system. I'm using tar 1.13.25-6 and
cron 3.0pl1-81.


Any help is appreciated!

TIA, Jukka
--
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~
--
To UNSUBSCRIBE, email to debian-user-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Colin Watson
2003-12-11 12:30:20 UTC
Permalink
Post by Jukka Salmi
I still couldn't solve my problem. I stripped down the script to the
$ cat ~/bin/tapetest
#!/bin/sh
cd /
/bin/tar -czf /dev/nst0 dir
echo "tar returned $?"
$ ~/bin/tapetest
tar returned 0
tar (grandchild): gzip: Cannot exec: No such file or directory
tar (grandchild): Error is not recoverable: exiting now
tar returned 141
Sounds like your cron job doesn't have an appropriate path. Try setting
PATH=/usr/bin:/bin explicitly at the top, adding any other directories
you need.
--
Colin Watson [***@flatline.org.uk]
--
To UNSUBSCRIBE, email to debian-user-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Jukka Salmi
2003-12-11 12:50:17 UTC
Permalink
Post by Colin Watson
Sounds like your cron job doesn't have an appropriate path. Try setting
PATH=/usr/bin:/bin explicitly at the top, adding any other directories
you need.
That's it! There was a typo in cron's $PATH. Thanks a lot!

Jukka
--
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~
--
To UNSUBSCRIBE, email to debian-user-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Loading...