1

Ubuntu server with users

root  
www-data  
mywebsite1  
mywebsite2

There are multiple websites hosted on this server, each with their own user.
Each website has their own cron jobs mostly backing up files and sending emails.

Should I run all cron jobs using a universal user like www-data or root?
Or should I run the jobs as the specific user for each site as each cron job is specific to the individual site?

2

Generally, cron jobs that do things like "backup files" and "send email" need to do so within the context of the user whose files they are manipulating. This ensures that they have permission to read and write the files, and that actions taken can be audited as corresponding to that user.

So you will want to run the cron jobs as the user on whose behalf they act.

| improve this answer | |
1

That depends on the type of cronjon.
Example 1:

wget http://domain.com/cron.php

In this case doesn't matter the running user.
Example 2:

/usr/bin/php /var/www/domain.com/cron.php

In this case i would run with the same user the virtualhost is running (in case each vhost has own user). Because the script might create files/folder or attempt to write them, and you don't want root owned files/folders undex domain.com.

Third case: PHP running as mod_php or CGI scripts without suexec (usually in this case the ftp user differs from the user under which the scripts are running). In this case the scripts could run as the ftp user or the webserver's user - www-data. Depends.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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