1753819 Members
8324 Online
108805 Solutions
New Discussion юеВ

cron jobs

 
SOLVED
Go to solution
augusto cossa
Frequent Advisor

cron jobs

Good Day all,

I would like to schedule in my crontab file that every 12 hours run the command to find core files and them delete them. So I have the below command, but I'm not sure if it's correct, PLS correct me if it's rong.

* 12 * * * /usr/bin/find / -name core -exec rm {} ;

Thanks,
A Cossa
8 REPLIES 8
Andreas Voss
Honored Contributor
Solution

Re: cron jobs

Hi,

syntax is correct:
Every day at 12:00 your find command will be executed.

Greetings

Andrew
Wiboon Tanakitpaisal
Occasional Advisor

Re: cron jobs

* 12 * * * /usr/bin/find / -name core -exec rm {} ;
don't forget to put "" before ";"

Hi everybody
Andreas Voss
Honored Contributor

Re: cron jobs

What Wiboon means is the \ before the ;
This is a forums problem that the \ is not displayed if you pusched it only once.
So to push the \ you have to type it twice (only for forum).
I think augusto has type the \ correctly.
Wiboon Tanakitpaisal
Occasional Advisor

Re: cron jobs

* 12 * * * /usr/bin/find / -name core -exec rm {} \;
don't forget to put "\" before ";"
Hi everybody
augusto cossa
Frequent Advisor

Re: cron jobs

Hi all,

Thanks to all. Know it working as I scheduled.

A Cossa
Alan Riggs
Honored Contributor

Re: cron jobs

Actually -- your present syntax will run the find command every minute from 12:00 to 12:59. What you want is:

0 12 * * * /usr/bin/find / -name core -exec rm {} \;
Richard Lathom
Occasional Advisor

Re: cron jobs

ACTUALLY, the command will only run ONCE each day (24 hours) not once each 12 hours. The correct syntax for every 12 hours would be, for example:

0 0,12 * * *

This would run at 00:00 and at 12:00 each day.
Bill Hassell
Honored Contributor

Re: cron jobs

As another point of view: for all POSIX shell users, you can set ulimit to eliminate core files from ever being created. For really big programs (more than 20 megs), this will really slow down everything on the system as the core dump process is run at kernel priorities. Add this to /etc/profile:

# set ulimit (if running POSIX shell)

if [ "$0" = "-sh" ]
then
ulimit -c 0
fi

ulimit -a will show the settable options. ulimit in ksh is a programmatic interface to setrlimit/getrlimit


Bill Hassell, sysadmin