> /var/log/program.log" >> mycron ...">

Store cron log in timedate file

I have this code currently:

echo "20 0 * * * cd /var/www/test/ && ./prog >> /var/log/program.log" >> mycron

      

This works great, but now I want to store it in a file at time intervals each time in a format like this:

program_YYYYMMDD_HHMMSS.log

      

Can anyone tell me how I can do this? I think I need to use a date variable, but I'm not sure how to implement it.

+3


source to share


1 answer


Yes you are right. You can use a date variable.



echo "20 0 * * * cd /var/www/test/ && ./prog >> /var/log/program_$(date "+%Y%m%d_%H%M%S").log" >> mycron

      

+1


source







All Articles