ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
The nake of the file doesn't matter nor does the location.
I would create a directory called "cron" in the home dir of the user it will be run as:
/root/cron
In that put:
/root/cron/jobs
/root/cron/logs
I put all my scripts in the jobs directory and output the logs to the logs directory (same name as the job with a .log extension)
In the /root/cron dir I create my cron files. If there is only one server it is usually "cron.standard" if it is a 2 system failover "cron.master" and "cron.slave". To load a crontab file (eg cron.standard) run:
crontab /root/cron/cron.standard
You cna check that it has loaded using:
crontab -l
I have only dealt with CRON on Solaris, but I ran into lots of problems with extra spaces and newlines in my cronfile. Be careful about them, seems that cron is sensitive to them. Especially newlines after your line
That is just where you put the files. So a cron file say "cron.standard" could be:
0 * * * * /root/cron/jobs/backup.pl 2>&1 > /root/cron/logs/backup.log
Ok, so, I have this cron file. I call it cron.mine (?) and put it in cron/jobs. It says:
0 10 * * /root/cron/jobs mail -s pengun "It's 10 o'clock" root
to let it email me whenever it's 10 o'clock. (tell me if i'm right.)
oh, and would it email to user penguin or user root?
The example I was giving was if you were wanting the jobs to run as root. If it is to be run as another user eg yourself I would use:
/home/penguin/cron
/home/penguin/cron/jobs
/home/penguin/cron/logs
I always put the cron dir under the users home directory.
sadly, I just killed(ish) my linux drive... must reformat
NEVER delete things as root unless it's one thing and you must read it carefully, never just say y y y y y y to "do you wanna delete this?" because bad things happen..
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.