6 Replies Latest reply on Mar 24, 2016 5:40 AM by Ondrej Kieler

    Cron job is not running

    Ondrej Kieler
      Share This:

      Hello,

       

      I created cron job named addm_backup.cron in path /usr/tideway/etc/cron/. Content of cron job is this:

       

      #******************************************************************

      # cron job to run the root node key extract and appliance backup on a daily basis

      # Run the Production nitvlxbf Scanner backup at 02:05 everyday (5 2 * * *)

      5 2 * * * /usr/tideway/etc/cron/addm_backup.sh

       

      It should starts this job:

       

      #!/bin/sh

      # To debug the script use -ev, where -e forces exit on error

      # and -v outputs commands on STDOUT

      export TIDEWAY_HOME=/usr/tideway

      export OUTFN=$TIDEWAY_HOME/log/addm_backup.log

       

       

      echo "BACKUP START ****************************************************************************" >> ${OUTFN};

      date >> ${OUTFN};

      echo "Save the root node keys in ~/data/customer/kex_file.xml" >> ${OUTFN};

      echo "/usr/tideway/bin/tw_root_node_key_export -u backup.user -p some-password /usr/tideway/data/customer/root_node_key_export.xml" >> ${OUTFN};

      /usr/tideway/bin/tw_root_node_key_export -u xxx -p xxxx /usr/tideway/data/customer/root_node_key_export.xml &>> ${OUTFN}

      echo "/usr/tideway/bin/tw_backup -u backup.user -p xxxxxxxxxxxxx --stop-services --notes='ADDM Scanner Daily Scheduled Backup to Proxy' --backup-smb --host=xx.xx.xx.xx --share=backup$ --backup-dir=nitvlxbf --remote-user=xxxxxxxxxxxxx" >> ${OUTFN};

      /usr/tideway/bin/tw_backup -u backup.user -p xxxxxxxxxxxxx --stop-services --notes='ADDM Scanner Daily Scheduled Backup to Proxy' --backup-smb --host=xx.xx.xx.xx --share=backup$ --backup-dir=nitvlxbf --remote-user=xxxxxxxxxxxxx --remote-password=xxxxxxx

       

       

      After creating this I run command  tw_cron_update, but job is not starting. Is there any mistake in cron job. Or do you have any idea what could be wrong?

       

      Thanks

        • 1. Re: Cron job is not running
          Kerryn Wood

          Hi Ondrej,

           

          Is the cron not running at all, or is it a matter for the script not working? Does the script have executable perms?

           

          It's worth redirecting the output of the cron to a log file because there may be an issue there. Also, when redirecting output to a log it's always worth using ${OUTFN} 2>&1 to make sure you catch stderr too.

           

          In the script itself, I would single quote the passwords if they have special characters.

          • 2. Re: Cron job is not running
            Ondrej Kieler

            Hello Kerryn,

             

            thanks for reply. Yes script has all permissions. I have just run it mannually and it ran without problems. It seems that something is wrong with cron. Or not?

            • 3. Re: Cron job is not running
              Kerryn Wood

              There's nothing wrong with that cron that I can see.

               

              To check the actual cron is OK manually look at the file to ensure all is as it should be.

              [root@host]# cat /var/spool/cron/tideway

               

              You could update the cron to create a marker to show for sure it's running or not:

              5 2 * * * ls -l /usr/tideway/etc/cron/addm_backup.sh >> /usr/tideway/log/crontest.log 2>&1; /usr/tideway/etc/cron/addm_backup.sh >> /usr/tideway/log/cronrun.log 2>&1
              1 of 1 people found this helpful
              • 4. Re: Cron job is not running
                Ondrej Kieler

                I see this in /var/spool/cron/tideway

                 

                The Tideway crontab file should NOT be edited manually.

                # Please add or edit .cron files in $TIDEWAY/etc/cron and then run

                # $TIDEWAY/bin/tw_cron_update to update changes.

                #

                # crontab format:

                # min (0-59) hour (0-23) day(1-31) month(1-12) wkday(1-7) command

                # ex: 30 23 * * * rm /home/someuser/tmp/*

                #******************************************************************

                MAILTO=""

                # /usr/tideway/etc/cron/addm_backup.cron

                #******************************************************************

                # cron job to run the root node key extract and appliance backup on a daily basis

                # For Wincor-Nixdorf schedule

                # Run the Production nitvlxbf Scanner backup at 02:05 everyday (5 2 * * *)

                5 2 * * * /usr/tideway/etc/cron/addm_backup.sh

                 

                Is that correct?

                • 5. Re: Cron job is not running
                  Kerryn Wood

                  Is that the whole of start of the file? In which case it's quite broken but hoping it's just a copy/paste issue.

                   

                  I would have expected to see:

                  [root@host ~]# cat /var/spool/cron/tideway

                   

                  #******************************************************************

                  # The Tideway crontab file should NOT be edited manually.

                  # Please add or edit .cron files in $TIDEWAY/etc/cron and then run

                  # $TIDEWAY/bin/tw_cron_update to update changes.

                  #

                  # crontab format:

                  # min (0-59) hour (0-23) day(1-31) month(1-12) wkday(1-7) command

                  # ex: 30 23 * * * rm /home/someuser/tmp/*

                  #******************************************************************

                  MAILTO=""

                  # /usr/tideway/etc/cron/addm_backup.cron

                  #******************************************************************

                  # cron job to run the root node key extract and appliance backup on a daily basis

                  # For Wincor-Nixdorf schedule

                  # Run the Production nitvlxbf Scanner backup at 02:05 everyday (5 2 * * *)

                  5 2 * * * /usr/tideway/etc/cron/addm_backup.sh

                  • 6. Re: Cron job is not running
                    Ondrej Kieler

                    Yes, it was copy paste mistake. So I will create redirection to log files to see what is happening there. Thanks for advices.