ok please explain what's the difference between running a cron as a user and putting cron in the line and just running corn as root anyway.Martin Frezman wrote:This is precisely why you should drop the sudo in all your "normal"/"terminal" commands. You don't need it (really, seriously, and you can ignore anyone who says you do) and, as you've discovered, it can screw you up (you end up with files owned by root and not writable by pi).
Instead, as I stated above, you should just put the 'sudo' in the crontab file (i.e., as part of the command to run). Then your crontab entry looks just like the command you would use to run the program "manually" (i.e., from the shell/terminal) and everything is as it should be.
And any comments by any other posters to the effect that you can't put "sudo" inside a crontab line - can, as you now know, be ignored.
if you tried this on any other linux, other than raspbian that is, you would find putting sudo in a cron line would not work as you need to enter your password to elevate a use to root using sudo. so you have to run cron as root.