I need to run a script daily. The script should be run as a specific user (ex. user1) not as root. So I put the cron file at /etc/cron.d and put the user name in the line (2nd column). But it gives an error saying that the command is not found. I suspect that the script was not run as user1's environment. Did I miss something?
Crontab running as a specific user
cron
Best Answer
Only
/etc/crontab
and the files in/etc/cron.d/
have a username field. In that file you can do this:From root's crontab
sudo crontab -e
you can use:Or you can use the user's actual crontab like this:
The second column in any crontab file is for the hour that you want the job to run at. Did you mean the sixth field?