How to write an Auto scripting for deleting old files using
shell script and made a cron job to run on daily basis
Answer / amit bondwal
#!/bin/bash
find /home/amitbondwal/ -type f -mtime +30 -exec rm -f {} \;
done
#change the directory path or name and number of days
#according to your requirement. This script will delete all
#the file older than 30 days in /home/amitbondwal directory
save the above script in a text file and run it by crontab
crontab -e
00 02 * * * /bin/sh /home/amitbondwal/scriptname.sh
This setting will run this script at 2 AM everyday.
| Is This Answer Correct ? | 12 Yes | 0 No |
In a file , how to retrieve the lines which are the multiples of 50 ? like 50,100,150th lines etc.
What is the difference between a shell variable that is exported and the one that is not exported?
Write a shell script to looking at the log file to see if the test has passed or not
What is Linux language details
What command needs to be used to take the backup?
what are special characters and explain how does text varies by the usage of single quotes,double quotes and back quotes?
how to print the 2-d, 3-d arrays in unix shell script programs please answer thi questio to my mail venusaikumar@gmail.com
Explain about "s" permission bit in a file?
Why we are writting shell scripts? Plz if possible explain it briefly.
I want to upload a file to remote server through ftp daily.Can anyone suggest how to make a shell script for that.I hv credentials for that ftp
What is the difference between scripting and coding?
What is in a script?