August 25, 2010

Running job in regular intervals or daily in Linux to delete files or modifying files

Running scripts daily to perform some common tasks in Linux
Be in root mode, super user mode
1) Create a script with the name filename.sh or any other name whatever you like
2) Do any one of the following .. but please test it with some other file extension like .yourname or something .. create your own unique files and do the testing before executing on original files which may be important.
   
   find /folderpath -type f -iname "*.fileextension" | xargs -i '{}' rm -rf {}
   (or)
   find /folderpath -type -f -iname "*.fileextension"  -exec /bin/rm -rf {} \;
3) chmod +x filename.sh
4) crontab -e
    i) press i to go into insert mode
    ii) enter 30 20 * * 1-5 /bin/bash /fullpath        
                      //30 min 20 hour i.e 8:30pm on 1-5(mon-fri) on *(every month) on *(every year)
    iii) shift+ZZ to save the file
5) Try this and let me know if any modifications needed

For further details, contact me psrdotcom@gmail.com

No comments:

Featured Post

Java Introdcution

Please send your review and feedback to psrdotcom@gmail.com