Topic
2 replies Latest Post - ‏2013-02-07T18:09:49Z by SystemAdmin
SystemAdmin
SystemAdmin
6908 Posts
ACCEPTED ANSWER

Pinned topic crontab - output file

‏2013-02-06T17:46:11Z |
Good Afternoon! I am kind of new at this but I am trying to set up a cron job. Below is the cron job that I have set up using crontab -e on an AIX server.

23 10 * * 1-5 CjisReturn >> /LGS/DEVELOPMENT/CLERK.DATA/AL.CJIS.CRON.LOG/CronReturnLog.txt 2>&1

The above output will be appened to the file named CronReturnLog.txt and this seems to work fine.

My question is, can I make this key for my file dynamic?

Currently the log is keyed CronReturnLog.txt but I would like to use the current date for the key, is there a way to do this in crontab -e?

Any information would be greatly appreciated, thanks for your tiume...

Thomas
Updated on 2013-02-07T18:09:49Z at 2013-02-07T18:09:49Z by SystemAdmin
  • The_Doctor
    The_Doctor
    88 Posts
    ACCEPTED ANSWER

    Re: crontab - output file

    ‏2013-02-06T21:30:11Z  in response to SystemAdmin
    There are many ways to do this. Google is probably your best friend when it comes to this stuff. Anyway here's a couple of examples:
    
    23 10 * * 1-5 CjisReturn >> /LGS/DEVELOPMENT/CLERK.DATA/AL.CJIS.CRON.LOG/Cron.$(date \+\%y\%m\%d).ReturnLog.txt 2>&1   # be sure to escape \ the special characters otherwise you can expect undesireable results when run under cron
    

    OR
    
    23 10 * * 1-5 /home/root/bin/skelton.script
    

    then the skelton.script contains
    
    #!/bin/ksh WHATEVER=$(date +%y%m%d)                    # 
    
    do pretty much whatever you want here   /full path name may be needed/CjisReturn >> /LGS/DEVELOPMENT/CLERK.DATA/AL.CJIS.CRON.LOG/Cron.$WHATEVER.ReturnLog.txt 2>&1
    
    • SystemAdmin
      SystemAdmin
      6908 Posts
      ACCEPTED ANSWER

      Re: crontab - output file

      ‏2013-02-07T18:09:49Z  in response to The_Doctor
      Hey, this is great information. Exactly what I was looking for. Thank you so much for your help...