Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 1661  / 1 Year ago, sat, may 20, 2023, 2:55:15

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:



SHELL=/bin/sh
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 )
#


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


More From » cron

 Answers
6

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.


[#35754] Saturday, May 20, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
edgehogight

Total Points: 272
Total Questions: 113
Total Answers: 99

Location: Northern Mariana Islands
Member since Sun, Jul 19, 2020
4 Years ago
edgehogight questions
Sat, Sep 11, 21, 22:09, 3 Years ago
Sat, Nov 6, 21, 19:48, 3 Years ago
Fri, Aug 26, 22, 09:37, 2 Years ago
;