I want to have a scheduled crontab run on a daily basis but not as the root user. Reasons being that this is a simple backup and cleanup job and I don't want any accidents. The backup folder will have permissions for user 'mysql-backup' (for example) and I want the crontab to only run as user mysql-backup. Obviously I don't want the mysql-backup user logged in or anything like that for the crontab to work.

any help will be appreciated.

link|improve this question
feedback

4 Answers

you can either edit the desired user's crontab (crontab -e -u mysql-backup) or use su or sudo to change to that user at runtime in root's crontab.

link|improve this answer
feedback

run sudo crontab -u <user> -e.

link|improve this answer
feedback

If you're root, you can just su to the user, and create a crontab.

That should work.

Something like this should work fine.

su kyle -c "crontab -e"

whistles to himself

crontab -u kyle -e

Obviously that's what I meant.

Since it wasn't explicitly answered, a user does not have to be a normal user, or have login rights, or anything like that to have a working crontab.

link|improve this answer
feedback

For system crontab, /etc/crontab, the 6th field is the user. For the crontab used by the user run crontab -e as that user and edit it's crontab. The crontab for users is stored in /var/spool/cron/<username>

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.