Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|improve this answer

run sudo crontab -u <user> -e.

share|improve this answer

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.

share|improve this answer

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>

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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