Page 1 of 1

crontab -e will not edit crontab but crontab -l will list it? - pi Jesse

Posted: Wed Sep 27, 2017 8:37 pm
by stickneyar
I have tried to edit the crontab file to run a program at reboot,

when I enter sudo crontab -e it indicates no file exists for pi

when I enter sudo -E crontab -e I get the file I previously edited using sudo nano crontab -e and it is correct, but when I go to save it ctr-X it saves it to /tmp/crontab.xxxxx/crontab where xxxxx is different every time.

If I go to /tmp directory no crontab.xxxx file or directory exist.

I have changed the save directory to /tmp/crontab many times and when I exit no change is made.

If I enter sudo crontab -l it displays my file perfectly.

Any ideas
Ray

Re: crontab -e will not edit crontab but crontab -l will list it? - pi Jesse

Posted: Wed Sep 27, 2017 9:40 pm
by pcmanbob
Buy using sudo crontab -e you are editing roots Cron file.
If you want to edit pi's Cron file the use crontab -e

crontab always saves to a temp file first once it checks the file for sanity it installs in the Cron file.
It normally repots this as installing new Cron file

Re: crontab -e will not edit crontab but crontab -l will list it? - pi Jesse

Posted: Wed Sep 27, 2017 9:53 pm
by DougieLawson
Stop using sudo.

Re: crontab -e will not edit crontab but crontab -l will list it? - pi Jesse

Posted: Wed Sep 27, 2017 10:00 pm
by Martin Frezman
And, for that matter, stop using crontab.

cron (and crontab) has all sorts of traps that catch up the unwary. Unless you really have a reason to use this bit of 70s/80s technology (or if, like many of us, you grew up on cron/crontab and you really, thoroughly, understand it), you're better off just skipping it.

Other, more modern methods exist. Probably the most straightforward is to setup a "systemd" service.

Note that I said "most straightforward"; I didn't say "the best".