How to Run cron job as Regular non-root User

By | 2013/08/21

Instead of putting all of your server’s cron jobs as root, consider having them in a regular user’s crontab. This is better for security reasons as well as good general practice. I’ll show you how!

One example is if you need apache to run a cron for your website. Run this cron as the apache user www-data instead of root. (User www-data is for Debian or Ubuntu of course.)

To edit www-data’s cron jobs, try this:

$ sudo crontab -u www-data -e

Type in your cron job, save and you are all set.

In the cron logs, you will see the command being run by this limited user instead of root:

2013-08-22T01:20:01.875684+00:00 chicago cron[26885]: (www-data) CMD (

Rock on,