On 23/06/16 07:14, mmoutaweh wrote:
Can any one help me how to create a cron job to permanently delete log
files every 60 min?
I have done the below to schedule a cron job that runs daily:
I created the following file in /etc/cron.daily/
and set DAILY_TIME=“10:00” to run the script.[/color]
In your original thread in the SLED Forums you wanted to run a script
daily hence my advice to create a file in /etc/cron.daily - as jmozden
has already advised for hourly you should move the file to /etc/cron.hourly.
Note also that the DAILY_TIME setting in /etc/sysconfig/cron will not
have an effect on hourly jobs.
I also restarted the cron by using “rccron restart”.
How can we set this to work on hourly basis and how to make this start
running directly as I was told that the above will need around two days
to start executing?[/color]
You might also want to look at the process creating the log files -
perhaps there is a setting to not be so verbose when logging thus not
create such large files? Or if you don’t actually want the log files to
simply not log in the first place?
Another idea could be to use logrotate to “manage” the log files. By
default logrotate is run daily via /etc/cron.daily/logrotate but you
could create an hourly version:
- copy /etc/cron.daily/logrotate to /etc/cron.hourly/logrotate (you
might want to use a different file name i.e. logrotate-hourly)
- edit /etc/cron.hourly/logrotate to reference a different configuration
file (i.e. /etc/logrotate-hourly.conf)
- copy /etc/logrotate.conf to /etc/logrotate-hourly.conf
- edit /etc/logrotate-hourly.conf to point at a different logrotate.d
directory (i.e. /etc/logrotate-hourly.d)
- create a file in /etc/logrotate-hourly.d to handle
Just an idea but this way you could have some archives of recent log
files/entries rather than just throwing them all away every hour.
I am still new user for SUSE and Linux, please advise.[/color]
Don’t worry, we all have to start somewhere.
SUSE Knowledge Partner
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below. Thanks.