Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Now I want to use Backup and Whenever gem to automatic backup my database. When I connect the server by ssh as an added user to run backup perform -t my_backup,it works well.But the cron file:

0 22 * * * /bin/bash -l -c 'backup perform -t my_backup'

can't run at 22:00. When I use cat /etc/crontab check the cron's config file,it is:


# 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 )

The /bin/bash and /bin/sh are different.What's the reason?How to do?

share|improve this question
For a command that simple the shell should not matter. In fact, you're doubling up on it since it will now use sh to run bash to run backup. You should be able to just skip running the shell yourself and be fine. – Jeff Snider Sep 5 '12 at 22:35
ServerFault is usually be a better place for this sort of question. This one might be migrated by a moderator soon. – Jeff Snider Sep 5 '12 at 22:40
up vote 1 down vote accepted

The most common thing I run into with cron not running something is that without a MAILTO set, if the command produces output cron will immediately stop it. Or possibly it tries to write to stdout and encounters a SIGPIPE. Not sure the exact mechanism.

Add MAILTO=<your email address> and give that a try. Alternatively, write both stdout and stderr out to a log file by appending >>/var/log/backup 2>&1 to the cron line you already have.

share|improve this answer
I have added MAILTO=<my_email_address> to /etc/crontab file.But I didn't receive a mail.And >>/var/log/backup 2>&1 method didn't get a backup result.It is strange. – Jingqiang Zhang Sep 6 '12 at 1:37

crontab is a config file. Why not edit it and change sh to bash?

share|improve this answer
I have edited it,but return a same result:-( – Jingqiang Zhang Sep 6 '12 at 1:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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