Need up to 30 seconds to load.
hello everyone this is ali and welcome
to my channel
in this video i'm going to show you how
to delete files that are older than a
few days
with cron tab in a previous video i
created a python script
on this elasticsearch machine is the
cento centos linux machine
it backs up the configurations of my
firewall
and saves them on the same machine and
then in another video i created a cron
job
to automate this script to run at 10 pm
every day but right now on the same
machine i want to find the files
or the configuration files that are
older than six days
and then i will delete them because i
don't want to keep
more than six days worth of files so to
do that i
first have to find the files and i will
use the absolute path of the find
command
in this directory right here
and this is everything that i have
and you can specify everything so
star.com everything that ends with dot
conf
or if you have different other types of
files you can say
find in this directory dash
name and you can specify whatever
file that ends with um any extension you
need
so right here star.conf it finds
everything
ending with dot conf so i'm going to use
this line
to find files that are older than 6 days
you have to use the minus that
our dash m time
plus 6 and now it
found those two files from august 22
and uh 21 and 22
and then after i found those files that
are older
older than six days i have to run the
command that will remove them
i'll say dash exec or minus exec
remove rm you can say dash type
file and you have to use the curly
brackets
the curly brackets will be the
placeholder
of the file or
it's the path name for the file file
found by the find
command and then you have to end
with a semicolon but you have to escape
it so that the interpreter does not
um so that you avoid interpretation
of the semicolon but i'm not going to
use it right here so i'm going to copy
it
and i'll go to cron tab
right now dash l to list what i have
i only have the python script that's
running this one
this python script at 10 pm
dash e to edit i'll
press i to go to the insert mode
and i will copy it right here and
before i exit i have to specify the time
because
it has to be automated so if the python
backup script is running at 10 pm 22
o'clock i will do this one
at 22 o'clock and 30 minutes
of every day every month every weekday
and now i press escape to exit insert
mode
colon write quit or wq enter
and now i have
those two cron jobs a backup script
that runs at 10 pm and then
this command that finds the files that
are older than six days
and then deletes them
at 10 30 every day
thank you guys for watching if you liked
the video please like and subscribe
and i will see you in the next one