These two lines are very different, aren't they?
sudo crontab -e
vs.
crontab -e
crontab -e is just 'per profile,' just for the one user, right? While 'sudo crontab -e' is for the whole OS, right?
Code: Select all
sudo crontab -e
Yes, although it is probably not such a good idea to think of them as "files", as much as a system functionality where each user has his own crontab functionality. Even though they are usually stored as (separate) files, conceptually, there's no reason why it couldn't all be sorted in a single database.
No, you could just as easily do it by invoking "sudo" from pi's crontab. Opinions vary on whether or not this is a good idea (some here violently believe that it is not and that people who do it are sub-human life forms), but I personally think it is much easier to keep track of things by having it all in the default user's (i.e., pi's) crontab, than having it spread all over the place.I think the sudo one was the only way I could get an update/upgrade automated before. I was looking into it again but it's been a while.
Code: Select all
$ sudo apt-get update
$ sudo apt-get upgrade
$
Well... That dependos. If you want to run a cron job that requires root permissions, putting it in the root crontab would certainly be a logical choice. I use it for (for instance) changing the backlight setting on an RPF display.Martin Frezman wrote: ↑Thu Sep 28, 2017 3:45 pmNot really. There isn't really any concept of "The whole OS".
The command:
which should never be used, edits the crontab file for a specific user, namely "root".Code: Select all
sudo crontab -e
Bzzzt! Wrong.W. H. Heydt wrote: ↑Thu Sep 28, 2017 4:51 pm
Well... That dependos. If you want to run a cron job that requires root permissions, putting it in the root crontab would certainly be a logical choice. I use it for (for instance) changing the backlight setting on an RPF display.
This I wouldn't mind knowing a little more about. Can you tell me or point me in the direction of how that works please? You just add files in a folder and cronjobs will run from those?DougieLawson wrote: ↑Thu Sep 28, 2017 5:15 pm
Put a file with a crontab line (single part name, no qualifiers) in /etc/cron.d
My method may not be "approved", but it isn't actually "wrong" as it works. Like many things in *nix, there are multiple ways of accomplishing this, even if some may be preferred over others. At best, you should have said "not the generally recognized as preferable method."DougieLawson wrote: ↑Thu Sep 28, 2017 5:15 pmBzzzt! Wrong.W. H. Heydt wrote: ↑Thu Sep 28, 2017 4:51 pm
Well... That dependos. If you want to run a cron job that requires root permissions, putting it in the root crontab would certainly be a logical choice. I use it for (for instance) changing the backlight setting on an RPF display.
Put a file with a crontab line (single part name, no qualifiers) in /etc/cron.d