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


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. LAMP
  3. Verify Cron is Running

Verify Cron is Running

Scheduled Pinned Locked Moved Solved LAMP
cron
9 Posts 3 Posters 1.7k Views 3 Watching
  • 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 Offline
      J Offline
      JLX89
      wrote on last edited by girish
      #1

      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!

      girishG 1 Reply Last reply
      0
      • J JLX89

        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!

        girishG Offline
        girishG Offline
        girish
        Staff
        wrote on last edited by girish
        #2

        @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
        0
        • girishG 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 Offline
          J Offline
          JLX89
          wrote on last edited by
          #3

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

          nebulonN 1 Reply Last reply
          0
          • J JLX89

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

            nebulonN Offline
            nebulonN Offline
            nebulon
            Staff
            wrote on last edited by
            #4

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

            J 1 Reply Last reply
            0
            • nebulonN nebulon

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

              J Offline
              J Offline
              JLX89
              wrote on last edited by
              #5

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

              nebulonN 1 Reply Last reply
              1
              • J JLX89

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

                nebulonN Offline
                nebulonN Offline
                nebulon
                Staff
                wrote on last edited by
                #6

                @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
                0
                • nebulonN nebulon

                  @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 Offline
                  J Offline
                  JLX89
                  wrote on last edited by JLX89
                  #7

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

                  girishG 1 Reply Last reply
                  0
                  • J 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!

                    girishG Offline
                    girishG Offline
                    girish
                    Staff
                    wrote on last edited by girish
                    #8

                    @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
                    1
                    • girishG 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 Offline
                      J Offline
                      JLX89
                      wrote on last edited by
                      #9

                      @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
                      1
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Bookmarks
                        • Search