Neddie
Posts: 35
Joined: Tue Feb 02, 2016 6:45 am

Crontab not running

Fri Nov 15, 2019 11:49 am

Hi all.
I'm sure Im doing something stupid but I cant get any crontab jobs to run :0(
Even a simple one like this does nothing
1 * * * * sudo touch /home/pi/test.txt

that command works from the command prompt.
I've tried crontab -e and sudo crontab -e , neither work.
Any ideas?
Cheers
Ned

Ernst
Posts: 1334
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: Crontab not running

Fri Nov 15, 2019 12:08 pm

Neddie wrote:
Fri Nov 15, 2019 11:49 am
Hi all.
I'm sure Im doing something stupid but I cant get any crontab jobs to run :0(
Even a simple one like this does nothing
1 * * * * sudo touch /home/pi/test.txt

that command works from the command prompt.
I've tried crontab -e and sudo crontab -e , neither work.
Any ideas?
Cheers
Ned

Code: Select all

1 * * * * /usr/bin/touch /home/pi/test.txt
The road to insanity is paved with static ip addresses

User avatar
rpdom
Posts: 17172
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Crontab not running

Fri Nov 15, 2019 12:11 pm

Your cron jobs should work.

crontab -e will edit the crontab for the current user (pi). I just tested this

Code: Select all

1 * * * * touch /home/pi/crontest
and it worked. A file was created at 12:01 as expected.
(I omitted sudo because the touch command doesn't need it in this case)

sudo crontab -e will edit the crontab for the root user. sudo is not needed in the crontab entry as the commands are already being run by the root user.

Are you running a standard Raspbian OS? It looks like you are.
Unreadable squiggle

User avatar
RaTTuS
Posts: 10559
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Crontab not running

Fri Nov 15, 2019 12:16 pm

and don't use sudo in cron
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

Return to “Beginners”