Friday, July 26, 2019

Cronjob for every month last Saturday.

Hi All,

Client have a requirement that they want to execute a script last Saturday of every month. So we keep as below.

30 01 * * 6 [ $(date +"\%m") -ne $(date -d 7days +"\%m") ] && sh /home/appeprd1/scripts/Interface_tables_purge.sh > /home/appeprd1/scripts/error.log 2>&1

This works as expected.You can modify according your requirement says last thursday/friday. Just change 4(for thursday) and 5 ( For friday). It works.

Thanks.