![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Check error after delete files. | icemania | Shell Programming and Scripting | 2 | 07-24-2007 08:22 PM |
| File System Check using shell script !!! | csaha | Shell Programming and Scripting | 7 | 01-03-2006 01:36 AM |
| Script to check for a file, check for 2hrs. then quit | mmarsh | UNIX for Dummies Questions & Answers | 2 | 09-16-2005 11:46 AM |
| Tidying up temp files on exit of script | Bab00shka | UNIX for Dummies Questions & Answers | 2 | 09-11-2002 03:13 AM |
| What are core files and how can I delete them when am performing system maintenance?? | IMPORTANT | UNIX for Dummies Questions & Answers | 6 | 04-04-2002 12:39 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Script to Delete temp files and check file system
Hi all, new to the threads as well as Unix/Linux. I need to create a script that will delete any temporary files as well as check the files on the system for errors or corruption. This is what I have so far and I'm sure that I'm missing things or have the wrong commands. I'm not sure where to go next or how to incorporate the two. Any help would be much appreciated. Thanks in advance.
#!/bin/bash #This script will automatically delete temporary files rm -rf /tmp/* rm -rf/var/tmp/* fsck -A exit |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
OK, lets go through it step by step:
Quote:
Code:
#! /bin/bash Code:
rm -rf /tmp/* rm -rf/var/tmp/* Code:
find /tmp -type f -atime +2 -exec rm -f {} \;
Code:
fsck -A Code:
if [ $(df -k /tmp|<some-filter>) -le <some-value> ] ; then
exit 1
else
exit 0
fi
I hope this helps. bakunin |
|
#3
|
|||
|
|||
|
To answer your first question it's a Linux system. Thanks for your help, you're description made it a lot easier to understand what I was really trying to do. I really appreciate it, bakunin.
|
|
#4
|
||||
|
||||
|
if its linux, there is alerady some scripts that delete what CAN be deleted from /tmp at boot time, (or when the system is going down)
|
||||
| Google The UNIX and Linux Forums |