Scheduler / Cron

I discovered a problem with pasteable code from the scheduler (index.php?module=Schedulers&action=index). If you add the line as root to cron, you will get wrong permissions of files in the cache and sessions-directory (root:root). To avoid this, check that the script is run as the same user as your www-server, eg www-data in debian. This way you will have correct permissions for the files, and probably also the maintenance will be able to delete old files instead of having hundredsofthousands of root-owned files filling up your sessions directory…

So the line to be pasted in the crontab-file should look like this:

          • cd /path/to/suitecrm; su -c ‘php -f cron.php’ -s /bin/bash www-data > /dev/null 2>&1



1 Like

Yes, this needs to be fixed and made clearer for users:

Maybe it’s easier to insert the given command but in the correct crontab, the one belonging to user www-data:

sudo crontab -e -u www-data

and there is where you can insert the command just as proposed by the installer.

thanks for the suggestion. I prefer to have all cron as root. Makes it easier to maintain one crontab on my system instead of having them scattered under different users :slight_smile: Now that i figured out that permissions get screwed up, i run the cront-schedule as the www-user.

The suggestion at github is a very good porposion for fixing this problem. I actually add to most of my scripts a check who runs the user, and if it’s root, then i exit. But til then, it would not require too much effort to add a more complete example or warning about running the cronjob a wrong user :slight_smile:

I assume you mean you are using the system-wide crontab available in some distro (like Ubuntu) by doing
sudo nano /etc/crontab
and adding a column to specify which user the job runs under. That’s a perfectly good configuration as long as cron.php runs with the same user as the web server (www-data).

If you could go to the github issue and vote up, by adding a “thumbs up” to the initial text of the issue (the long first comment), it would help guarantee that it gets the necessary attention. Thanks.