Filip
Filip

Reputation: 105

PHP Cronjob on different users

I try to run cronjob, which execute php script and which also is added from php script.

I trying it on localhost. When php add cron, it is added as daemon user and job doen not execute. When I add the same cron as I or as root cron will execute. Is exist any perrmiosions for that?

In cron logs, there are the same logs for daemon,I and root users, withour errors.

In addition, when I add some other cron to daemon crontab for example:

* * * * * touch tmp/test.txt

then it will be work, and file will be created. I tried to change permiossions for files, but it not solved problem. What could be the reason of that?

Upvotes: 0

Views: 157

Answers (2)

Filip
Filip

Reputation: 105

ok, problem is solved. I put crontabs from txt file, which was generated from php. Php added on end of all lines '^M' which crashed jobs. I saw that when i opened crontab with vi editor.

Upvotes: 1

Henry
Henry

Reputation: 607

you can edit a users crontab with -u.

e.g. edit crontab for www-data:

sudo crontab -u www-data -e

Upvotes: 1

Related Questions