I am having a very strange issue... I'm using a script to use tar and
gzip to backup critical data on my computer to an external USB drive.
When I run the script by hand as root it works perfectly taking about an
hour to complete, file size ends up as 12Gb.
However, as a cron job it ends up being 5.5Gb and only taking half an
hour. When I run tar -tf archive.tar.gz it gives me an unexpected EOF
error at the end.
The cron job is as root, so its in /etc/crontab but I also get no output
anywhere. Why would this happen? Especially since it WORKS when I do
it from the console, and no it never asks me anything either.
Any ideas?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHXZMYStZoE1nza5gRAwaFAKC6anGjift8VaLMpngnuKYL9ZlHiACeNUp9
So9be+bt4+Z1hFir0IuQ4Gk=
=MRsC
-----END PGP SIGNATURE-----
1) does root (or your main user) have mail from crontab to explain the
failing? if not, check cat /var/log/messages | grep -i cron
2) does cron have a feature whereby it kills processes that have been
taking too long? An interrupted tar op would create an unexpected
EOF. Try running "file bkp.tgz" to see that the header is intact.
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Linux
> Users Group. To post a message, send email to
> linuxus...@googlegroups.com To unsubscribe, send email to
> linuxusersgro...@googlegroups.com For more options, visit
> our group at http://groups.google.com/group/linuxusersgroup
> -~----------~----~----~----~------~----~------~--~---
>
<Just Guessing>
Maybe crond timeouts the task. And the backup stops...
Maybe you should make that task background adding an ampersand to the command
in crontab.
If any questions post here the contents of the crontab.
Check the logs. Another trick would be to have the cron job fire up a
screen session with a full root login. For example, here's how to run
"sleep 1000" in a screen session with a root login:
screen -S sleep -d -m su - root -c "sleep 1000"
Once the screen session starts you can connect to it and watch it.
Regards,
- Robert
No, and that is very strange, I have it setup to output verbose, so I
should get a mail with its full output as I do with other tasks, I do
not, there is no mail from it.
I checked /var/log/messages, nothing to suggest a problem.
> 2) does cron have a feature whereby it kills processes that have been
> taking too long? An interrupted tar op would create an unexpected
> EOF. Try running "file bkp.tgz" to see that the header is intact.
I am running a test right now, so the process is actively running from
cron after changing some options in the actual tar command line, it has
not stopped yet, so I'll have to get back to you on this one.
I can't find mention anywhere of how one would tell cron how long a
process can run, my only other idea was that the system runs this
normally at 5am every morning. Does anything by the system get run at
5:30 am that might kill it?
Here is my crontab:
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts
--report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts
--report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts
--report /etc/cron.monthly )
# Check IP address and update dynamic DNS
00,30 * * * * root update-dyndns.sh
# Runs a complete system backup, must watch for running out of HD space.
0 5 * * * root backup-tar.sh >&
/media/mybook250/info/backup-result.txt
# Run sensor checks, shuts down the system in the event that sensor
# output violates min/max settings in /etc/sensors.conf
* * * * * root sensors|sensor-check
I added the redirect to try to get some output from it, so far the file
is never created so I must assume there is no output.
Ok, one, how do I make that cron job run in that screen, two, how do i
connect to it?