Cron on alternate weeks - Simple hack
The below cron entry will run a script file at 5am on every Sunday.
0 5 * * 0 sh script.sh
Simply include the below three lines in your script to swap your actual code file with an empty file on every run.
cp GetData.php Temp.php
mv Swp.php GetData.php
mv Temp.php Swp.php
GetData.php = actual code
Swp.php = blank file
This will run the code only on alternate weeks.
0 5 * * 0 sh script.sh
Simply include the below three lines in your script to swap your actual code file with an empty file on every run.
cp GetData.php Temp.php
mv Swp.php GetData.php
mv Temp.php Swp.php
GetData.php = actual code
Swp.php = blank file
This will run the code only on alternate weeks.
Comments
Post a Comment