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?
feedback
|
|
Only
From root's crontab
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? | |||||||||||
feedback
|
|
You may need to set the PATH for that user, if the executable you're using is in, say, /usr/local/bin. To set the PATH, put something like this before the cronjobs:
The other way is to fully specify the path to sample_executable in your cronjob, so:
If sample_executable refers the executables not in the standard PATH, you should use the first option. | ||||
|
feedback
|
|
The typical directory for user crontabs is in /var/spool/cron/crontabs. The file format is the one that doesn't include the username. User crontabs are owned by the user and named after the user with mode 0600. This is best handled by writing your tab file and using | |||
|
feedback
|