0

This is strange. On my Raspberry Pi (Debian) I can manually run a php file without a problem. However, I get this error when it is executed with a cron job:

/bin/sh: 1: /var/www/html/sunrise-sunset.php: not found

My cron job (using crontab -e) is as follows:

* * * * * php /var/www/html/sunrise-sunset.php >> /var/www/html/logbook.log 2>&1

However, when I add the shebang "#!/usr/bin/php" on the php page, the file is executed but all commented lines (*/ xxx */) are also read. Of course, this results in a lot of errors. When I remove those comments, it's a 'not found' error again. What could be the problem here?

Jim
  • 41
  • 5
  • Two items: check the ownership and permissions of sunrise-sunset.php. Your user may be able to run them but the cron user may not be allowed. Do you have any errors in the systems / cron log? – David J Eddy Nov 20 '15 at 16:29
  • Oops, you're right, @CBroe. I was in the process of shutting down for the day and whipped out an answer without enough thought. I've deleted the answer. – Jeffwa Nov 21 '15 at 13:06
  • Thank you for your answers. Meanwhile, I copied the code and pasted in a new empty php file. Weirdly enough, this fixed my issue while the permissions are still the same. Alright, well: problem solved! – Jim Nov 22 '15 at 11:25
  • Does this answer your question? [CronJob not running](https://stackoverflow.com/questions/22743548/cronjob-not-running) – tripleee Jan 20 '21 at 08:16

0 Answers0