I've set up crontab tasks to be executed every min.

* * * * * sudo /usr/bin/php /root/scrapers/terra_plf/terra_swap_api.php

I see its log in var/log/syslog file:

Jan  3 15:14:01 clearthefog CRON[26579]: (root) CMD (/usr/bin/php     /home/admin/scrapers/terra_plf/terra_swap_api.php)
Jan  3 15:15:01 clearthefog CRON[26623]: (root) CMD (sudo /usr/bin/php /root/scrapers/terra_plf/terra_swap_api.php)

Yet, nothing is written into DB as the file terra_swap_api.php should do. Any suggestions why? Any way to check if the file is actually executed?

When I run the same script in CLI it work perfectly: php terra_swap_api.php

1 Answer 1


You cannot simply sudo in cron, since it will ask for the sudo password. You'd have to setup passwordless sudo for that command.

Since the php file is in the /root dir (take note it's a security concern), you could install the crontab as root (sudo crontab -e) and put the line in there (without sudo).

If your script doesn't require root privileges, you could run without sudo, but you'd have to move the files to a readable location, since /root is owned and restricted to the root user.

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.