LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   cron job questions (https://www.linuxquestions.org/questions/linux-software-2/cron-job-questions-430269/)

heeru 03-31-2006 05:30 AM

cron job questions
 
I was reading up on cron jobs and am not sure where exactly we need to set this up? Which file?

I put entries in the /etc/crontab file, will that work?

A simple command like rm -rf <filename> gets executed in the above crontab file.

However, a command like
"10 4 * * * root find /usr/local/phoneweb/logs -name "pw_metricsfile*" -mtime +7 -exec rm -f {} \;" does not delete the files even after 10 days.

Any help will be appreciated. Thanks!

acid_kewpie 03-31-2006 06:43 AM

that should be fine, but the syntax of the actual command to run get's confused easily. personally i would make a seperate script file with a useful name, i'd guess something like /var/scripts/rm_old_phoneweb_logs.sh, and just call that script on it's own from the crontab file. just make that script executable and you'll get a better level of clarity an abstraction in your crontab as it can just get really messy anyway.

timmeke 03-31-2006 06:47 AM

You typically need to do
crontab -e
to edit the crontab settings for your user.
You can also do:
crontab some_file
where some_file contains your crontab settings.
The /etc/crontab* stuff is done for system-wide cron jobs (ie logwatch & logrotate). Only root can probably use those. But root can have his own crontab settings too.

Crontab settings (per user, not for the entire system) are typically stored in /var/spool/cron or something like that. On my FC3 box, /var/spool/cron contains a file with the cron settings from one specific user. The file has the same name as the user.


All times are GMT -5. The time now is 08:34 PM.