Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
361 views
in Technique[技术] by (71.8m points)

how to consolidate these CRON jobs, removing files older than X days

I need to have a CRON job which removes files and folders older than 14 days within a specified folder. I outlined this as 5 CRON jobs, and my webhost came back that I need to have it in 2 or less CRON jobs. Apparently they are not willing to figure out the CRON job syntax for consolidating things, and also do not provide me with any troubleshooting on the syntax. Some of the CRON methods I have attempted to achieve this on other servers has fallen short with empty folders remaining. Here is what I had originally sent them:

"Please create these 5 CRON jobs for my account, each job running once, daily. time of day does not matter, set to an off-peak time of your choosing.

for the folder '/www/public_html/mac/images/192.168.1.195_0012176140b3' delete all files in that folder and subsequent subfolders which are older than 14 days old.

for the folder '/www/public_html/mac/cache' delete any .txt extension files in that folder which are older than 14 days old.

for the folder '/www/public_html/john/images/192.168.1.200_00121775e08a' delete any files in that folder and subsequent subfolders which are older than 14 days old.

for the folder '/www/public_html/john/cache' delete any .txt extension files in that folder which are older than 14 days old.

for the folder '/www/public_html' delete any empty folders which are subsequent subfolders within that folder."

I could add a folder between the public_html folder and the john and mac folders to simplify the way the CRON is written.

question from:https://stackoverflow.com/questions/65843922/how-to-consolidate-these-cron-jobs-removing-files-older-than-x-days

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...