I read all the related questions and was unable to understand them. I am using Plesk CPanel to set cron job as it was advised by everyone.
Delete files older than 30 days using cronjob. Hi, i am a newbie to all this. I run a file uploading site call mp3host.info what i want to do is some sort of cron job comand or tiney php or cgi script that deletes file if it is older than 30 days in sepecific folders. Cron Question - Delete files in a dir older than 48 hours? I would like to share my Cron job for Close and Delete indices from elasticsearch 5.4. First installed elasticsearch-curator. Then created /etc/elasticsearch-curator folder for config files Created below files on that folder. Curator.yml (config file) action_close.yml (close action file) action_delete.yml (delete action file).
I want to delete all files from a folder after 24 hours. Assume that I have to delete it after every 2 mins (So I can check its working or not).
Dec 11, 2008 Set up a cron job to delete log files every day This is a discussion on Set up a cron job to delete log files every day within the Linux Support forums, part of the Tech Support Forum category. I'm new to cron.
I have two options:
I tried both ways and was unable to get my task completed.
Here is the pic of cpanel scheduled task:
I want to delete files from folder var/www/example.com/public/js/complied
. All files inside this complied
folder should be deleted. I don't know which to write in Command textfield.
Should I use the following command?
Or should I execute a php file?
The source code of this Cron.php is:
I have tested this code and it works fine.
Thanks in advance.
If you have access to your Server or SSH, you can simply add it to your crontab.
In your SSH just type
you will see a list of cron jobs on it, just append this line of code to your cronjob:
The code above means that every 10am in the morning you are removing all the files in the path you provide. Please refer to this link for more info about Cron: http://en.wikipedia.org/wiki/Cron
it worked for me to delete in once a day
if you want to remove everything in this folder, but leave the folder itself:
To optimize MrCleanX' solution a bit, use xargs
:
Instead of calling rm for each file to delete, xargs
packs many files together to a single call to rm
The -print0
and -0
stuff is to make both find
and xargs
using NULL terminated strings, which is necessary to handle file names with space and other interesting chars in their names.
댓글 영역