Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.