Cronjob not running as apache
Solution 1:
There are different solutions:
- Add your user to apache group
www-data
,nobody
, or whatever it is called on your system. You need also to grant the group write permission. - Run the cron job under apache user. This can be done using a command like:
sudo su apache_user -c "crontab -e"
. However, this may not work depending on whether it is allowed to switch to apache user and add cron jobs forapache_user
.
I think point 1 should be better.
Solution 2:
It's best run the cron job as your apache user:
sudo crontab -u apache_user -e
This is a cleaner solution compared to running the job as you, because what belongs to apache should stay such. Mixing of users will bring mess and could produce problems at some point.