Cron Job with a Script
Hi All,
I like to create a cron tab to a script if df = 97% goto /var/log delete *.logs and reboot Anyone know how to create a script like that? If so how to do it? What is the command line? Also it needs to be scheduled every 2 weeks. I dont see oen for "weekly" Thanks Joe |
I am not sure what log files you are deleting, but you might want to check out logrotate.
If that doesn't work you could do something like this and put in a script and schedule a cron job. Code:
# find files older than 7 days and delete them Code:
df = 97% df -h shows disk usage If you want to schedule it in cron, here is a how to for cron. http://aplawrence.com/Basics/bbcronbasics.html Here are 2 guides for bash scripting. http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html http://www.tldp.org/LDP/abs/html/ |
Hi
Thanks for emailing back. This line= # find files older than 7 days and delete them find /tmp -type f -mtime +7 | xargs -- rm -f -- seems to bea good idea for me. Basically, i have a script in /root/reboot.sh ---cd /var/log/log.* reboot The log files are created as a result of other scripts to keep track etc.. proprietary u can say so its ok to delete them I want to a "crontab" to ro run the reboot.sh every 2 weeks. I was reading to crontab I dont see option for every 2 weeks. I saw @weekly how would I put that in place? Bottom line is i need a delete and reboot done every 2 weeks? Can a crontab do it? What is the command line? Thanks for your thoughts Joe |
I believe that you would have to schedule one job for the 1st day and on job for the 15th day.
05 00 01 00 * /usr/sbin/<script name> # day 1 05 00 15 00 * /usr/sbin/<script name> # day15 You need to put this in your crontab file. Do a slocate crontab to find it. I would look into logrotate for rotating the logs and use cron to reboot the system. Just curious, why do you need to reboot every 2 weeks? |
I think log level for message is set too high or something
/dev/hda --get to 100% and stops people from going yahoo.com etc external sites so we have to delete the messages log and reboot the system anyway I can give more space to the hda? thanks |
All times are GMT -5. The time now is 11:24 PM. |