Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can anyone help define what this cron does please for each command?

find /home/root/public_html/_sess -type f -mtime +3 -name 'sess-*' -execdir rm -- {} \;

I feel like I understand find , but I’m not 100% sure what -type is, I think that is the file type f not sure yet -mtime I feel like -mtime means a time setting of some sort, and +3 means maybe that time setting +3? , I feel like -execdir rm -- just means remove the files in the directory call -name 'sess-*' as well. But again not 100% sure of all the command elements within and wanted to get clarification please.

Thank you for any help, hope not to get beat up to bad on this question, I’m not finding answers quickly on my own.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can do man find to get information on how Linux find works and all the options you can pass to it.

In this case, the command is using the Linux find utility to search for files in the /home/root/public_html/_sess directory with the following options:

-file f – searches for files of filetype f, which is regular files (not directories, links, etc)

-mtime +3 – searches for files modified more than 3 days ago (the + is for more than, -3 would be less than 3 days old)

-name 'sess-* – searches for files whose name matches the regex sess-* (name starts with "sess-")

-execdir <command> {}; – executes <command> on each file that find finds in the directory that the file was found in, in this case <command> is rm to remove the file

So in summary, this job searches for files located in a certain directory, whose names start with a specific string, and which are more than 3 days old, and deletes them.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading