Forum Discussion

Sumit_Kumar_Dub's avatar
Sumit_Kumar_Dub
Icon for Nimbostratus rankNimbostratus
Jun 25, 2019

Steps to configure cron jobs to execute commands | F5 BIG IP LTM 13.X

Hi All,   I need help to configure cron job to run below two commands on hourly basis. Could you please help me with the steps:   tmsh run cli script certificatereports.tcl > /var/tmp/cert-output...
  • jaikumar_f5's avatar
    Jun 27, 2019

    Had this replied yesterday in the codeshare, nevertheless will add the same comment here - hoping it could help someone in future.

     

    Hi Sumit,

     

    Apologies on the late reply, Good to know that you already have smtp set.

    The next easy step is to put a small script with any mail agent (sendmail or mail or mailx) and have that script run on cron for every month.

     

    Goto /var/tmp/ and create a file as automatecertificatereports.sh.

    Add the below code inside the automatecertificatereports.sh file.

    #!/bin/sh
    tmsh run cli script certificatereports.tcl > /var/tmp/cert-outputs.txt
     
    from="abc@domain.com"
    to="abc@domain.com,pqr@domain.com,xyz@domain.com"
    subject="Automated SSL Certificate Report"
     
    mail -s "$subject" -r "$from" -a "/var/tmp/cert-outputs.txt" "$to" << EOF
    Hi Team,
     
    Please find the attached SSL Certificate Report.
     
    Thanks & Regards,
    abc@domain.com
     
    EOF

    Change the permission to executable one.

    chmod +x automatecertificatereports.sh

    Now goto your crontab & do a list first to see the existing cron jobs running.

     

    crontab -l

    You should see some couple of disk monitors check etc etc.

     

    Always put some good comments before you make an entry of your cronjob, Use crontab -e to edit/add your entries.

    crontab -e

    Goto the of the section and the below 2 lines,

     

    ## Section for Automated SSL Certificate Report - Monthly Cron - Start of month - 6 O'clk ##
    0 6 1 * * /usr/bin/bash /var/tmp/automatecertificatereports.sh

    You can edit this cron value according to your need. For testing, try running this for every day 1 AM report - 0 1 * * *

    Hope this helps. Let us know if you have more concerns.