상세 컨텐츠

본문 제목

Cron Job Delete Log Files

카테고리 없음

by hiecequelycinia 2021. 5. 28. 14:41

본문

Active2 years ago

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:

  1. Either run a PHP file that deletes all files after 24 hours using a cron job
  2. Use the cron job command `rm` to delete all the files
Log

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?

How To Check Cron Logs

The source code of this Cron.php is:

I have tested this code and it works fine.

Thanks in advance.

user2290749user2290749

4 Answers

Cron Job Delete Log Files
MrCleanXMrCleanX

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

Cron Job Delete Old Log Files

JiNexusJiNexus
1,9691 gold badge15 silver badges16 bronze badges

it worked for me to delete in once a day

Cron Job Log Files

if you want to remove everything in this folder, but leave the folder itself:

Shuhad zamanShuhad zaman

To optimize MrCleanX' solution a bit, use xargs:

Can I Delete Log Files In Windows

Cron Job Delete Log Files

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.

Cron Job Logs

mogulmogul
3,2991 gold badge13 silver badges20 bronze badges

Not the answer you're looking for? Browse other questions tagged phpcroncrontabcron-task or ask your own question.

댓글 영역