Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to write an Auto scripting for deleting old files using
shell script and made a cron job to run on daily basis

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Where is bash history?

876


What happens on a system call?

962


How would you compare the strings in a shell script?

941


What is c in shell script?

1037


How can the contents of a file inside jar be read without extracting in a shell script?

1097


How do I open the shell in cmd?

1074


What does $@ mean bash?

1115


What are scripts in psychology?

1004


How will you copy a file from one machine to other?

962


write a shell script to emulate the Id command of PRIMOS which lists files and directories. It list files first with a header FILES and then directories with a header DIRECTORIES. This command has several options. The main ones are. -file select files only -dir select directories only -reverse sort in reverse order -no_header put no header on the output -brief output the header only -size display the size of each file -help display Id´s syntax and options.

2722


What is web script?

1051


Is bash an operating system?

940


How do you find out What is your shell?

1032


What is difference between shell and bash scripting?

953


Write a command sequence to find all the files modified in less than 2 days and print the record count of each.

1460