ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Cron Job - Troobleshooting

    IT Discussion
    9
    16
    948
    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.
    • WLS-ITGuyW
      WLS-ITGuy @Curtis
      last edited by

      @Curtis said in Cron Job - Troobleshooting:

      I have a script that runs a backup, and works perfectly, but for some reason it's not working via Cron. What is the best way to troubleshoot it?

      Can you give a screenshot of the cron job?

      1 Reply Last reply Reply Quote 0
      • JaredBuschJ
        JaredBusch
        last edited by

        Cron doesn’t run with your environment variables. Make sure to use full paths.

        C 1 Reply Last reply Reply Quote 6
        • Emad RE
          Emad R @Curtis
          last edited by

          @Curtis

          Pipe the cron job to a log file. Are you using Fedora ? (i noticed weird stuff in it with crontab)

          1 Reply Last reply Reply Quote 0
          • C
            Curtis
            last edited by

            Ubuntu 18.04

            1 Reply Last reply Reply Quote 0
            • C
              Curtis @JaredBusch
              last edited by Curtis

              @JaredBusch said in Cron Job - Troobleshooting:

              Cron doesn’t run with your environment variables.

              I have variables in the script, that should be fine, correct?

              scottalanmillerS 1 Reply Last reply Reply Quote 0
              • C
                Curtis
                last edited by Curtis

                Here is the Cron Job:

                0 0 * * * /root/auto-backup.sh
                
                1 Reply Last reply Reply Quote 0
                • M
                  manxam
                  last edited by

                  @Curtis : can you show us the contents of the .sh file?

                  1 Reply Last reply Reply Quote 0
                  • DustinB3403D
                    DustinB3403
                    last edited by

                    @Curtis said in Cron Job - Troobleshooting:

                    Here is the Cron Job:

                    0 0 * * * /root/auto-backup.sh
                    

                    That's a very simple cron job, what error do you get when it runs?

                    1 Reply Last reply Reply Quote 0
                    • C
                      Curtis
                      last edited by Curtis

                      @DustinB3403 One would think, right? 🙂 No errors. Maybe there is a log somewhere?

                      DustinB3403D 1 Reply Last reply Reply Quote 0
                      • DustinB3403D
                        DustinB3403 @Curtis
                        last edited by

                        @Curtis Look in the logs.

                        C 1 Reply Last reply Reply Quote 0
                        • C
                          Curtis @DustinB3403
                          last edited by

                          @DustinB3403 where?

                          1 Reply Last reply Reply Quote 0
                          • RomoR
                            Romo
                            last edited by Romo

                            @Curtis check:

                            tail -n 500 /var/log/cron.log
                            
                            or
                            
                            journalctl  | grep CROND
                            
                            1 Reply Last reply Reply Quote 0
                            • scottalanmillerS
                              scottalanmiller @Curtis
                              last edited by

                              @Curtis said in Cron Job - Troobleshooting:

                              @JaredBusch said in Cron Job - Troobleshooting:

                              Cron doesn’t run with your environment variables.

                              I have variables in the script, that should be fine, correct?

                              If they are all defined when run in an environment-less way.

                              C 1 Reply Last reply Reply Quote 0
                              • C
                                Curtis @scottalanmiller
                                last edited by Curtis

                                So I just figure out that at least part of the script is running, however the rclone doesn't seem to be syncing the data to the cloud. Maybe I'll break the script into 2 parts to troubleshoot. Funny thing is when I run it manually, it works great.

                                IRJI 1 Reply Last reply Reply Quote 0
                                • IRJI
                                  IRJ @Curtis
                                  last edited by

                                  @Curtis said in Cron Job - Troobleshooting:

                                  So I just figure out that at least part of the script is running, however the rclone doesn't seem to be syncing the data to the cloud. Maybe I'll break the script into 2 parts to troubleshoot. Funny thing is when I run it manually, it works great.

                                  Are you testing as root when running manually?

                                  1 Reply Last reply Reply Quote 0
                                  • 1 / 1
                                  • First post
                                    Last post