1

I have a cronjob created using this tutorial: http://www.matt-helps.com/automatic-backup-of-mysql-database-to-s3/

It works when i run this command sudo sh s3BucketBackupScript.sh

But I can't get it run properly when configuring it in Cron. The script is modded with +x.

I configured it using sudo crontab -e as follows:

# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command

* * * * * /bin/sh /home/ubuntu/s3BucketBackupScript.sh

but no results. I think there is an empty line after the .sh lines. If I run the script without sudo it doesn't produce anything, so that's why I added it to sudo crontab -e.

Any hints would be very appreciated.

6
  • * * * * *? What is that to suppose to do? And I myself would have used "/etc/crobtab".
    – Rinzwind
    Feb 14, 2016 at 16:52
  • run every minute as I'm testing the script? Feb 15, 2016 at 8:39
  • and how long does that backup take? more then 1 minute?
    – Rinzwind
    Feb 15, 2016 at 8:41
  • no usually a second or 10 :) Feb 15, 2016 at 9:11
  • 1
    can you post the content of s3BucketBackupScript.sh?
    – Praveen VT
    Feb 23, 2016 at 8:51

2 Answers 2

0

Please, Do you check permission allow user run cron in file /etc/cron.allow. if it not have on server, you can create and add line:

## [root@test]# cat /etc/cron.allow
root
deploy

After add line ok, you can restart crond with command:

[root@test test]# service crond restart

If after change but its not run command, maybe you can use user root and add command example in crontab -e is:

* * * * * su - [user you must run command] -c "/bin/sh /home/ubuntu/s3BucketBackupScript.sh"

Add command ok, you should restart crond with command: [root@test test]# service crond restart .

I think with its maybe help you run command in crontab.

0

Please do check your s3BucketBackupScript.sh script and ensure there is no relative paths given.

CRON of an individual user sets the user's home directory as PWD.

This may worked manually from terminal because you were in the exact directory to interpret the relative paths correctly.

2
  • Thanks! I indeed removed a few relative paths.. (I guess all of them actually). Also, should I change this line from "0 3 * * * /bin/sh /home/ubuntu/s3BucketBackupScript.sh" to "0 3 * * * /home/ubuntu/s3BucketBackupScript.sh"? Feb 23, 2016 at 13:19
  • you could do like this, 0 3 * * * cd /home/ubuntu && sh s3BucketBackupScript.sh
    – Praveen VT
    Feb 26, 2016 at 9:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .