0

I have script that will run just fine from the command line by simply using “sudo pdfBackup” however when I added it to sudo crontab –e, it’s not running. The script is in my /bin/ directory called “pdfBackup”, inside this script is a simple command

#!/bin/bash 
rsync -az ~/files/content/pdf  ~/Dropbox

This is what my crontab file looks like

*/1 * * * * /bin/pdfBackup

I set it up for every minute while I am testing it. I can’t figure out why it’s not working. I have another cron job that runs successfully so I know cron is working.

Thanks in advance.

*Edit - I looked in the the syslog and this but no error or anything?

CRON[26774]: (root) CMD (/bin/pdfBackup)
4
  • I suspect ~/ doesn't mean what you expect it to mean, when the script is run via root's crontab Feb 15, 2016 at 16:36
  • You are right! I corrected the path to /home/user/.... and it is running properly now. Thank you.
    – audioboxer
    Feb 15, 2016 at 16:48
  • @steeldriver: could you convert that to an answer and leave me a comment so that I can upvote?) :-)
    – Fabby
    Feb 15, 2016 at 22:09
  • is this a shell script pdfBackup.sh?
    – Praveen VT
    Feb 26, 2016 at 9:22

1 Answer 1

0

My issues was that that I wasn't referring to the to and from directories in my script properly.

Since it is being run as root, the home directory is different than my user home directory.

4
  • It's best to use full paths when dealing with cron.
    – earthmeLon
    Feb 15, 2016 at 18:07
  • 1
    Welcome to Ask Ubuntu. ;-) You should allow the one that helped you to post an answer first, so that that user gets the rep for helping you. (Rep is all the payment we get for helping you...)
    – Fabby
    Feb 15, 2016 at 22:09
  • @dn-ʞɔɐq ɹW sure no problem. It wasn't posted as an answer and I didn't want to leave the question unresolved.
    – audioboxer
    Feb 16, 2016 at 18:35
  • @dn-ʞɔɐq ɹW: real wizardry there with yr screen name !! How did you manage that ?
    – Cbhihe
    Feb 17, 2016 at 21:08

You must log in to answer this question.

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