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 Path variable?What is its use?
write a shell script to find the largest number from 3 given numbers.
How will you connect to a database server from linux?
What is sudo command?
Write a shell program to test whether a given number is even or odd?
What is the equivalent of a file shortcut that we have a window on a linux system?
How shell works?
Hello all, This is my assignment on shell scripting, can anyone help me regarding this ? Create a shell script which connects to the database In second shell script include the first script for the DB connection Create a table (PRADEEP_DATA) with 2 columns (name, value) In Third shell script include the first script for the DB connection And insert/delete the values from the Table, by accepting input from the user This functionality should be a menu driven Program: 1) Insert to the database a. Name b. value 2)Delete from the database a.Name b.value Exception handling needs to be taken care.
what is info area how many types?
How would you print just the 25th line in a file using smallest shell script?
Calculate a real number calculation directly from the terminal and not any shell script.
write a non recursive shell script that accepts any number of arguments and prints them in the reverse order