Forum Discussion
Mic_108850
Altostratus
Apr 13, 2010"b" command in a crontab
Hi,
i'd like to set up a schedulded task on my BIG-IP LTM
The script should be run each day at the following hour:
09:10 and 11:10
The command included is to clear the RAMCACHE profile below:
b profile http TEST delete all entry
How to write a script included this command and how to create the crontab?
Thank you for your help
Mic
11 Replies
- hoolio
Cirrostratus
Hi Mic,
Can you try the following:
Create a script file. Edit the actual command you want to run inside the double quotes
echo "b profile command here" > /root/ramcache.clear.sh
Make the script executable by root
chmod 744 /root/ramcache.clear.sh
Edit root's crontab
crontab -e
Add the following two lines (from: http://www.thegeekstuff.com/2009/06/15-practical-crontab-examples/)
At 9:10 and 11:10, run the ramcache clear script on the active unit
10 9,11 * * * if [ `/bin/ps1` == "Active" ]; then /root/ramcache.clear.sh > /dev/null 2>&1; fi
Aaron - Mic_108850
Altostratus
Thank you Aaron for your quick answer.
I set it up.
How can i check the .sh is running correctly? do we have logs ?
Mic - hoolio
Cirrostratus
You could add logging to the script to see what it's doing. Replace the existing script with this named /root/ramcache.clear.bashSave the output file name as the script name OUT=/var/log/`basename $0`.out Print the date and script name echo "`date +%Y%m%d_%H%M%S`: `basename $0`: starting" >> $OUT List the current RAM cache entries for one HTTP profile echo "Entries before delete:" >> $OUT b profile http MY_HTTP_PROFILE ramcache entry show >> $OUT Delete current RAM cache entries for one HTTP profile b profile http MY_HTTP_PROFILE ramcache entry all delete List the current RAM cache entries for one HTTP profile echo "Entries after delete:" >> $OUT b profile http MY_HTTP_PROFILE ramcache entry show >> $OUT
And then remove the existing crontab entry and add this:
At 9:10 and 11:10, run the ramcache clear script on the active unit
10 9,11 * * * if [ `/bin/ps1` == "Active" ]; then /root/ramcache.clear.bash > /var/log/ramcache.clear.bash.out 2>&1; fi
The output will be logged to /var/log/ramcache.clear.bash.
Aaron - hoolio
Cirrostratus
Hi Mic,
Which version of LTM are you running? What bigpipe command are you running to list/clear the cache? If you run them from the command line without the script or cronjob involved do they work? If so, what happens if you run the script directly (/root/ramcache.clear.bash)? Do you see /var/log/ramcache.clear.bash.out being created?
Thanks, Aaron - Mic_108850
Altostratus
when i run the script directly i have:
~ /root/ramcache.clear.bash
-bash: /root/ramcache.clear.bash: Permission denied
It' LTM V10.1
i type this command to list the cache:
b profile http TEST ramcache entry all
no ramcache.clear.bash.out created
Mic - hoolio
Cirrostratus
Can you make the script executable by root:
chmod 744 /root/ramcache.clear.bash
And then rerun it?
Aaron - Mic_108850
Altostratus
ok the script runs correctly when i start it manually
but witt seems not working with crontab (this is what i have in my crontab):
cron tab for root
1-59/30 * * * * /usr/bin/diskmonitor
05 9,11,13,14,15,17,19,00,01 * * * if [ `/bin/ps1` == "Active" ]; then /root/ramcache.clear.bash > /var/log/ramcache.clear.out 2>&1; fi
Is this correct?
Mic - Mic_108850
Altostratus
for information i don't see a /bin/ps1 in my big-ip but only a /bin/ps
Mic - Mic_108850
Altostratus
Great it works with crontab
Can i leave it this way ?
Mic - hoolio
Cirrostratus
Good to hear. Yeah, that should be a safe way to check for the failover status in any LTM version.
You could comment out the debug logging in the bash script once you're done testing.
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects