Script to run cron on Alternate friday’s

1. Create script @ /home/Desktop/

2. Create file out @ /home/Desktop/out

3. Create directory cronlog in /var/log/cronlog

About script:

This script will run every Friday but execute cron on alternate fridays. When we run this script first time it will excute cron and put “0″ in “out” file. Next firday script will run again but it will find “0″ in “out” file, script will not execute cron but it will change “0″ to “1″ in “out” file. As next friday it will find “1″ in “out” file, it will execute cron and change “1″ to “0″… so on….


c=`cat /home/administrator/Desktop/out`
if [[ $c -eq 0 ]]; then
echo 1 > /home/administrator/Desktop/out
exit 0;
if [[ $c -eq 1 ]]; then
echo “Starting Script at : `date`” >> /var/log/cronlog/friday-error
echo “Starting Script at : `date`” >> /var/log/cronlog/friday-output
/usr/bin/php5 /var/www/info.php 2>> /var/log/cronlog/friday-error 1>> /var/log/cronlog/friday-output
echo “Stoping Script at : `date`” >> /var/log/cronlog/friday-error
echo “Stoping Script at : `date`” >> /var/log/cronlog/friday-output
echo 0 > /home/administrator/Desktop/out
exit 0;
4. Now setup cronjob in crontab, as mentioned below:
00 23 * * 5 /bin/bash /home/administrator/Desktop/
5. Where:
/bin/bash ← environment  to execute secritp
/home/administrator/Desktop/ ← path to script
6. Now on every friday you cant check logs to verify output/errors at: