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 |
What is a command line shell?
how to print the 2-d, 3-d arrays in unix shell script programs please answer thi questio to my mail venusaikumar@gmail.com
How can any user find out all information about a specific user like his default shell, real-life name, default directory, when and how long he has been using the system?
What is computer cli?
In a single command how do you run the previous command in the command prompt.
what are command line arguments? what is the need of those?
Create a bash shell script that reads a line from the user consisting of 5 words and then prints them out in reverse order. Name this script "reverse.sh"
How do you schedule a command to run at 4:00 every morning?
What is a batch file used for?
Explain about return code?
What is the purpose of scripting?
Is shell scripting a programming language?