Verify Cron is Running
-
@jlx89 After you restart the app, in the app logs you should see
==> Imported crontab
. It will also print an error if it could not parse the crontab correctly.For testing, you can put something like this in your crontab:
* * * * * echo "Cron ran at $(date)" >> /app/data/test.txt
Then, after a couple of minutes, I can see in
/app/data/test.txt
:Cron ran at Thu 29 Jul 2021 10:19:01 PM UTC Cron ran at Thu 29 Jul 2021 10:20:01 PM UTC
If the output above does not appear for some reason, maybe you can
systemctl restart box
and wait for sometime to see if that helps. -
@girish said in Verify Cron is Running:
-
-
-
-
- echo "Cron ran at $(date)" >> /app/data/test.txt
-
-
-
Thanks! So Cron is running, the output worked going to test.txt. But for some reason it doesn't seem to be running what I have setup. I'm also not seeing any errors in the logs. Is there another way to dig into it to find any issues?
-
-
@jlx89 The cron output has to be redirected to a file, it won't appear in the main application logs. I think it will be useful for the cron command to be able to redirect to main application logs. So, I have pushed an update to the LAMP app to make that possible. I put some notes here on how to do this after the update - https://docs.cloudron.io/apps/lamp/#cron-support.
So, after you update, you can try something like this:
1 * * * * (echo "Trigger is running now"; /usr/bin/php -d memory_limit=-1 -d max_execution_time=0 /app/data/public/path/to/task/trigger.php) > /proc/$(cat /var/run/crond.pid)/fd/1 2>&1
You will see both the echo and any php command output in the main application logs.
-
@girish said in Verify Cron is Running:
1 * * * * (echo "Trigger is running now"; /usr/bin/php -d memory_limit=-1 -d max_execution_time=0 /app/data/public/path/to/task/trigger.php) > /proc/$(cat /var/run/crond.pid)/fd/1 2>&1
Perfect, thank you so much! That worked out very well!