I have a backup script (rsync via ssh) which is run by cron (configured in /etc/crontab)

0 2   * * *   root    /bin/bash --login /opt/aebackup/sshbackup.sh

If I run it as logged in root like following it runs prefectly fine.

root@server:~# /opt/aebackup/sshbackup.sh

If I run it via cron it would just stop after a while (not always on the same task in the script.. it seems pretty random, like the process is killed at some point randomly)

Does anyone have an idea why my cron would do that? thanks for anything... I'm desperate!

  • i just found out something really weired.. doesn't make any sense to me. when i use following in crontab it works as expected and solves my problem: 0 2 * * * root /bin/bash --login /opt/aebackup/sshbackup.sh >> /whereever/sshbackup.log – brickinthewall Jun 22 '11 at 15:20

There was a bug in the old cron, for explanation see this launchpad entry.

| improve this answer | |

If you are not interested to an output you can just appen to your command >/dev/null 2>&1... this way it becomes

 0 2   * * *   root    /bin/bash --login /opt/aebackup/sshbackup.sh > /dev/null 2>&1

It should work fine this way, even if it's only a workaround for the bug.

| improve this answer | |

The answer may be in cron's log output.

It is in /var/log/syslog by default.

But it can be set up to create a separate cron.log, which is more useful.

This Q&A describes the process:

16.04: How do I make cron create cron.log and monitor it in real time?

Also in this answer is the instructions to create a wcron command that displays it is near-real-time. Plus, it links to another answer,

How to change cron log level?

that shows how to change the log level to include more than just the start of jobs - level 15 will show errors and end time, also.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.