Programming This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
07-23-2003, 02:35 PM
|
#1
|
|
Senior Member
Registered: May 2002
Location: Melbourne Australia
Distribution: it died/ macosx
Posts: 2,478
Rep:
|
all right, I'm an idiot. cron problems
heheh. I started a cron thread ages ago, but gave up in frustration before I could fix it.
So any way, I would like to ask someone to guide me through this step by step.
**********Here's what I know:********************
1)the format of dates..
2)I have a cron.allow and cron.deny file.
**********Here's what I don't know:**************
3)what to name the file (what extension)
4)where to put it
5)do I need to edit crontab?
anything not here I don't know, so tell me.
titanium_geek
|
|
|
|
07-23-2003, 02:43 PM
|
#2
|
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
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
|
|
|
|
07-23-2003, 04:28 PM
|
#3
|
|
Member
Registered: Mar 2003
Location: US
Distribution: Kubuntu 6.06
Posts: 173
Rep:
|
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
* 1 * 12 *
|
|
|
|
07-25-2003, 05:55 AM
|
#4
|
|
Senior Member
Registered: May 2002
Location: Melbourne Australia
Distribution: it died/ macosx
Posts: 2,478
Original Poster
Rep:
|
*david_ross* thanks. will try it out.
Oh, and how do you make sure that jobs go to "jobs" and logs go to "logs"?
*CodeWarrior* no, I don't think this is the problem... thanks though.
titanium_geek
Last edited by titanium_geek; 07-25-2003 at 05:57 AM.
|
|
|
|
07-25-2003, 06:00 AM
|
#5
|
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
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
|
|
|
|
07-26-2003, 09:11 AM
|
#6
|
|
Senior Member
Registered: May 2002
Location: Melbourne Australia
Distribution: it died/ macosx
Posts: 2,478
Original Poster
Rep:
|
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?
titanium_geek
|
|
|
|
07-26-2003, 11:02 AM
|
#7
|
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
If you are setting it up the way I suggested it would be the file:
/root/cron/cron.mine
Code:
# This is my cron file (cron.mine)
# Job 1, e-mail penguin when it is 10 o'clock
0 10 * * * mail -s "It's 10 o'clock" -u penguin 2>&1 > /root/cron/logs/mail-at-10.log
# Job 2, set the time every hour
0 * * * * rdate -s ntp.demon.co.uk 2>&1 > /root/cron/logs/rdate.log
# Job 3, backup using my backup script
30 2 * * * /root/cron/jobs/backup 2>&1 > /root/cron/logs/backup.log
I only use the jobs directory for puting the actual scripts in. If is is only a one liner then I wouldn't bother with a script.
This is only the way I do it because I find it easy to use regardless of the user.
|
|
|
|
07-27-2003, 04:42 PM
|
#8
|
|
Senior Member
Registered: May 2002
Location: Melbourne Australia
Distribution: it died/ macosx
Posts: 2,478
Original Poster
Rep:
|
thanks. makes more sense than any book or howto. so, how do I get it to recognise it's a cron comand thingy? if I just put it there will it work?
titanium_geek
|
|
|
|
07-28-2003, 03:32 AM
|
#9
|
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
No you will need to load the crontab file:
crontab /root/cron/cron.mine
You can check it has loaded using a listing:
crontab -l
|
|
|
|
07-28-2003, 06:43 AM
|
#10
|
|
Senior Member
Registered: May 2002
Location: Melbourne Australia
Distribution: it died/ macosx
Posts: 2,478
Original Poster
Rep:
|
Ah ha! finaly it looks like I can start to regrow my hair (after pulling it all out)
just checking: the full directory for /root/cron is /home/penguin/root/cron (??)
thankyou thankyou thankyou
titanium_geek
|
|
|
|
07-28-2003, 07:51 AM
|
#11
|
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
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.
|
|
|
|
08-01-2003, 10:28 AM
|
#12
|
|
Senior Member
Registered: May 2002
Location: Melbourne Australia
Distribution: it died/ macosx
Posts: 2,478
Original Poster
Rep:
|
yay! yay!
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..
ohwell
titanium_geek
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 11:20 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|