script for fedora core 4

Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Aug 2005
Posts: 74
Reputation: jindalarpan is an unknown quantity at this point 
Solved Threads: 0
jindalarpan jindalarpan is offline Offline
Junior Poster in Training

script for fedora core 4

 
0
  #1
Aug 11th, 2005
hey friends
i m facing one problem that on sever their is fedora core 4 and when ever temp(/tmp) is filled server go show.
can any one provide me with the script that can automatically cleans up /tmp after some days or when temp is going to fill

thanks
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 298
Reputation: Cain is an unknown quantity at this point 
Solved Threads: 2
Cain's Avatar
Cain Cain is offline Offline
Posting Whiz in Training

Re: script for fedora core 4

 
0
  #2
Aug 11th, 2005
First I would investigate the source of the problem. /tmp could have been made too small when the install occured or you could have a log file that is just in the wrong spot. move the log file to /var/log if applicable. make changes where appropriate.

I usually put all of my root level scripts in roots home area in a directory called scripts.
e.g. /root/scripts/script.bash

You could use /etc/cron.daily/tmpwatch
This is easiest I know it ships with RHAS3/4 so ti should ship w/ Fedora

Or you could write a script if the culprit filename is the same every time
the simplest form of script is just an executable file that starts off with the first line as:

!#/bin/bash -f

followed by the command you want to execute:
# use # as comment character
# echo out and append the bad file info and disk usage to /var/log/messages formatted cute of course..

/bin/echo "--------------------------------------" >> /var/log/messages
/bin/echo "Cron is running /root/scripts/script.bash" >> /var/log/messages
/bin/echo "--------------------------------------" >> /var/log/messages
/bin/date >> /var/log/messages
# list the contents of the directory before deletion so we have a record
/bin/ls -ltR /tmp >> /var/log/messages
# check disk usage before
/bin/du -sk /tmp >> /var/log/messages
#lets remove the file by common name (if the same every time)
/bin/rm -f /tmp/culpritfile.log
echo "Removed /tmp/culpritfile.log" >> /var/log/messages
/bin/date >> /var/log/messages
/bin/echo "--------------------------------------" >> /var/log/messages


feel free to copy this into a text file and modify as needed. this is a simple script
the '>>'s say "redirect output and append it to the end of specified file"
modify as needed

set as a nightly cron job while root using crontab -e

if youre not sure how hit the man pages
man tmpwatch
man cron

..or google em.


good luck,
Cain
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC