I have a bash script that checks to see if my PHP service is running, and starts it if needed.
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
KP=$(pgrep -P 1 -f script.php)
if [ "X$KP" = "X" ]
then
/usr/bin/nohup php /var/www/test/script.php >>/var/www/test/log.txt 2>&1 &
fi
I then added the following entry to crontab -e (as my user).
* * * * * /var/www/test/startup >> /var/www/test/cron.log 2>&1 &
The cron runs, and I can see the process when looking at htop. However, it doesn't seem to be working or writing to the logs. It just sits there using 0% of the CPU. the /var/www/test/ folder is owned by my and the log files have 666 permissions.
What is wrong? Or rather, what can I change to get the error logs working so I know what's wrong?
[1] 1858(the pid) and the process is running. It also seems to have written to thelog.txtfile.