On Tue, 28 Jan 2020 16:26:37 -0800
Ben Koenig <[email protected]> dijo:

>The whole point of setting the DISPLAY and XAUTHORITY variables to
>make it so you CAN open the window as root. Trying to use
>the .Xauthority for the root user won't work unless the X server was
>started by root. So you specify the .Xauthority for jjj, and as long
>as X is actually running then it works fine. Of course if something
>closes X in the middle of the night then yeah it's going to fail.
>
>You can try this on literally any distro, no guesswork is required.
>start your desktop, then hop out to a different VT (ctrl+calt+f2), log
>in, sudo su to root and then execute the following:
>DISPLAY=:0 XAUTHORITY=/home/<username>/.Xauthority xterm
>
>If this fails then X is either not running as the chosen user, not
>running at all, or has been configured using non-standard settings.
>Another possibility is that cron is not actually running commands as
>root.

In the case of my rsync commands the cron job was created by me on my
desktop from a terminal window with 'sudo crontab -e.' When nano popped
up the crontab it opened with the explanatory text at the top and a
notice that it was creating a new crontab because one didn't exist yet.
And I know that there already existed a crontab for me because I put a
job in it a long time ago.

This is the official way you're supposed to run cron jobs as root - you
put them in root's crontab.

>Am I wrong to assume that cronjobs are always run as root? I don't
>actually know since I don't mess with cron beyond the most basic
>options. Most of my cron tasks were made by point-and-click in FreeNAS.

It depends on what you want the cron job to do. If it's something that
might require root permissions (e.g., a backup of your root partition),
then it's going to have to be run as root or it will produce nothing
but a mass of 'permission denied' errors. In the case of my present
dilemma, I am backing up ~/, where you would think I own all the files,
so I could have put the script in my own crontab. But in reality there
are a bunch of files in your home folder (at least on my Xubuntu
computer) that were created by programs and owned by root. Yeah, this
is kind of stupid, but I decided it was easier just to run rsync -a as
root than to be forever trying to retake ownership of files. (And
thanks for explaining previously about -a, that was very useful.)
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug

Reply via email to