Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


    Cloudron Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    Solved Verify Cron is Running

    LAMP
    cron
    3
    9
    500
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      JLX89 last edited by girish

      Hello All!
      I am using Invision Community, have the cron jobs enabled, and restarted the app. But for some reason it doesn't seem to be running. Is there a way to verify that they're running (or not) and the best way to do that?

      Thank you!

      girish 1 Reply Last reply Reply Quote 0
      • girish
        girish Staff @JLX89 last edited by girish

        @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.

        J 1 Reply Last reply Reply Quote 0
        • J
          JLX89 @girish last edited by

          @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?

          nebulon 1 Reply Last reply Reply Quote 0
          • nebulon
            nebulon Staff @JLX89 last edited by

            @jlx89 maybe your specified command simply silently fails right away? How does your crontab line look like?

            J 1 Reply Last reply Reply Quote 0
            • J
              JLX89 @nebulon last edited by

              @nebulon I've pasted it below:

              1 * * * * /usr/bin/php -d memory_limit=-1 -d max_execution_time=0 /app/data/public/path/to/task/trigger.php {key to run trigger.php}

              Thank you!

              nebulon 1 Reply Last reply Reply Quote 1
              • nebulon
                nebulon Staff @JLX89 last edited by

                @jlx89 just to double check, I think this pattern would run the command "1 minute after every hour every day" is that what you had in mind?

                J 1 Reply Last reply Reply Quote 0
                • J
                  JLX89 @nebulon last edited by JLX89

                  @nebulon Yeah, that is what I was shooting for at the moment. I'll try changing it back to every minute and see if it kicks off again.

                  So hypothetically, you should see the cron run in the logs, correct?

                  Thank you!

                  girish 1 Reply Last reply Reply Quote 0
                  • girish
                    girish Staff @JLX89 last edited by girish

                    @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.

                    J 1 Reply Last reply Reply Quote 1
                    • J
                      JLX89 @girish last edited by

                      @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!

                      1 Reply Last reply Reply Quote 1
                      • First post
                        Last post
                      Powered by NodeBB