bleepian
Posts: 6
Joined: Mon Sep 09, 2013 11:55 am

Crontab issues

Sun Nov 02, 2014 11:08 am

I've got problems with crontab entries. Everything looks alright, I think, so I'm stumped here.

Setting up a rsync backup for another machine over ssh but having problems with that I'm trying some more basic stuff to see what might be wrong.

This works, so crontab works:
47 10 * * * /bin/echo "hello world" > /home/pi/hello

This does not work. It gives an empty ls-test file in home/pi.
53 11 * * * bin/ls /home/pi > /home/pi/ls-test

What might be wrong? I can't see anything incorrect. Tried both user crontab and su crontab.

DirkS
Posts: 9876
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Crontab issues

Sun Nov 02, 2014 11:15 am

Code: Select all

53 11 * * * bin/ls /home/pi > /home/pi/ls-test
There's no '/' in front of the path to 'ls', so the command is probably bot found.

Gr.
Dirk.

bleepian
Posts: 6
Joined: Mon Sep 09, 2013 11:55 am

Re: Crontab issues

Sun Nov 02, 2014 1:37 pm

Duh! Of course...
Now that works. Thank you.

Next step, I can't get this to work. Same thing, empty file in /home/pi. It does work in terminal, not in cron:
21 14 * * * /usr/bin/ssh -p 55555 [email protected] "/bin/ls /mnt/WORK/" > /home/pi/ls-work-test

And while I'm at it, this is what I want to finally do, can't get it to work in cron (Does work in terminal, key pair and such is setup so no password login required)
30 14 * * * /usr/bin/rsync -ra --exclude-from=/home/pi/rsync-excludes -e '/usr/bin/ssh -p 55555' [email protected]:/mnt/WORK/* /mnt/WORK-BUP/

eltrasimaco
Posts: 20
Joined: Fri Apr 25, 2014 10:50 am

Re: Crontab issues

Sun Nov 02, 2014 6:19 pm

As it's running in background, use the -n swith (ssh -n xxxxxxxxxxxxxxxx)

bleepian
Posts: 6
Joined: Mon Sep 09, 2013 11:55 am

Re: Crontab issues

Thu Nov 19, 2015 11:01 am

The issue was that cron uses sh and not bash... telling it to us bash instead makes it work.

21 14 * * * bash -c "/usr/bin/ssh -p 55555 [email protected] "/bin/ls /mnt/WORK/" > /home/pi/ls-work-test"

Return to “Raspbian”