DougieLawson wrote: ↑
Wed May 16, 2018 10:04 pm
peggyopal wrote: ↑
Wed May 16, 2018 3:40 pm
Okay, but is there a reason that editing the current user is preferred over editing the root user?
If the script you're running from cron doesn't need elevated privileges then don't run it from the root crontab. Don't use sudo when you don't need it. Don't run as root when you don't need it. That's part of Linux Security 101.
That's half of the answer - and the most important half. Since nothing in this current thread requires root privs to run, there is, of course, no reason to run it as root.
The other half is that if you do
need root privs in a cron job, then there are two ways to do it:
1) Put it in root's crontab - now you have two things to keep track of - which leads to confusion as we see this thread. Don't do this!
2) Put it in pi's crontab - and use 'sudo' like you normally do when you need to run stuff as root when running on the Pi.
Note: Yes. I am assuming the default configuration with "passwordless" sudo. If, as many of the big time forum posters do, you remove "passwordless" sudo, then this changes (and in that case, you ought to know what you are doing). But in the default config, it is better to keep everything in a single file. As already mentioned, this keeps things simple and trackable - and avoids the confusion that caused the problem in this thread.