LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Cron running as user writes log file as root (https://www.linuxquestions.org/questions/linux-newbie-8/cron-running-as-user-writes-log-file-as-root-4175573110/)

bgorilla 02-24-2016 09:26 AM

Cron running as user writes log file as root
 
I've got a cron in (cron.d) which runs nightly. It spawns a dspace index process as the 'dspace' user. This dspace index process writes to a /log directory many log files. The /log directory is owned by the dspace user...
drwxrwxr-x. 2 dspace dspace 4096 Feb 23 04:04 log
Now when this cron runs and the log files are written to the /log directory, they are written with root as the owner and group. I was thinking since dspace owns the /log directory and since the dspace process is spawned using the dspace user that the log files would be written being owned by dspace. So, when the cron runs I'm getting (Permission denied) errors.
Can someone please tell me where I'm going wrong on this?
Thanks

bgorilla 02-24-2016 10:31 AM

I think I may see why. The dspace script (file in /etc/cron.d was owned by root. I never changed the ownwer:group to dspace. I just changed it and I'll see if that fixed it.

Emerson 02-24-2016 10:43 AM

/etc/crontab is the system crontab for my systems, it has a field for user:
Code:

2 2 * * *      root    /sbin/fstrim /
The above command is run as root.


All times are GMT -5. The time now is 08:27 PM.