cron not reading tab
|
|
Thread rating:  |
Robert Peirce - 20 May 2008 11:47 GMT My crontab didn't run again last night. This is on a 10.5.2 server. I checked /var/log/system.log for the expected error and it wasn't there. Root's crontab did run. Permission are the same. It has run before.
Originally I had this set to run my personal calendar program at the same time root's tab ran calendar -a. I thought maybe cron could not run two jobs at once on 10.5.2. Then I thought maybe two instances of calendar could not run, so I changed it to run at 4:05. Nothing.
 Signature Robert B. Peirce, Venetia, PA 724-941-6883 bob AT peirce-family.com [Mac] rbp AT cooksonpeirce.com [Office]
Jolly Roger - 20 May 2008 21:34 GMT > My crontab didn't run again last night. This is on a 10.5.2 server. I > checked /var/log/system.log for the expected error and it wasn't there. [quoted text clipped - 4 lines] > run two jobs at once on 10.5.2. Then I thought maybe two instances of > calendar could not run, so I changed it to run at 4:05. Nothing. Did you sleep the computer last night? When the computer is asleep *nothing* runs.
 Signature Please send all responses to the relevant news group. E-mail sent to this address may be devoured by my very hungry SPAM filter. I do not read posts from Google Groups. Use a real news reader if you want me to see your posts.
JR
Robert Peirce - 21 May 2008 12:24 GMT > > My crontab didn't run again last night. This is on a 10.5.2 server. I > > checked /var/log/system.log for the expected error and it wasn't there. [quoted text clipped - 7 lines] > Did you sleep the computer last night? When the computer is asleep > *nothing* runs. It is a server. It isn't supposed to ever sleep. If it is awake at midnight it should be awake at 4AM. However, I don't really know for sure.
BTW, it did run last night. I edited my crontab yesterday. I wonder if cron "forgets" about it and editing reminds it?Is that possible?
 Signature Robert B. Peirce, Venetia, PA 724-941-6883 bob AT peirce-family.com [Mac] rbp AT cooksonpeirce.com [Office]
Robert Peirce - 21 May 2008 14:50 GMT > > Did you sleep the computer last night? When the computer is asleep > > *nothing* runs. [quoted text clipped - 5 lines] > BTW, it did run last night. I edited my crontab yesterday. I wonder if > cron "forgets" about it and editing reminds it? Is that possible? It wasn't asleep. The system.log was continuous through the night. Cron just didn't run my job for some reason. I am really starting to think that cron is forgetting jobs. I know it reads the tab when it is edited. Does it ever read it again? Maybe I could have root's tab touch the file once a day!
 Signature Robert B. Peirce, Venetia, PA 724-941-6883 bob AT peirce-family.com [Mac] rbp AT cooksonpeirce.com [Office]
Jolly Roger - 21 May 2008 15:09 GMT > > > Did you sleep the computer last night? When the computer is asleep > > > *nothing* runs. [quoted text clipped - 11 lines] > edited. Does it ever read it again? Maybe I could have root's tab > touch the file once a day! Have you tried placing a new entry in the table that logs to a text file or sends an email at regular intervals to see if that task fails as well?
 Signature Please send all responses to the relevant news group. E-mail sent to this address may be devoured by my very hungry SPAM filter. I do not read posts from Google Groups. Use a real news reader if you want me to see your posts.
JR
Robert Peirce - 22 May 2008 15:22 GMT > > > > Did you sleep the computer last night? When the computer is asleep > > > > *nothing* runs. [quoted text clipped - 14 lines] > Have you tried placing a new entry in the table that logs to a text file > or sends an email at regular intervals to see if that task fails as well? That's the interesting thing. When I do that it works. For example, I had an item to mail a test message to me every minute. That wnet on until I killed it.
The problem seems to be when an item is in there but inactive for some time, possibly a day. Editing the file with crontab -e seems to cause cron to look at it for at least the next day. Beyond that it gets iffy.
 Signature Robert B. Peirce, Venetia, PA 724-941-6883 bob AT peirce-family.com [Mac] rbp AT cooksonpeirce.com [Office]
Robert Peirce - 22 May 2008 15:27 GMT > > Have you tried placing a new entry in the table that logs to a text file > > or sends an email at regular intervals to see if that task fails as well? [quoted text clipped - 6 lines] > time, possibly a day. Editing the file with crontab -e seems to cause > cron to look at it for at least the next day. Beyond that it gets iffy. Here's the test message I was using:
# When cron does not seem to be working, test with this. # * * * * * mailx -s testing rbp
BTW, in case I didn't mention this, root's crontab works fine. We also have one for Admin to run SuperDuper once a week. That is working as well. It seems only to affect user's crontabs, but I am the only user using cron so it may actually be specific to mine.
 Signature Robert B. Peirce, Venetia, PA 724-941-6883 bob AT peirce-family.com [Mac] rbp AT cooksonpeirce.com [Office]
Chris Ridd - 22 May 2008 16:21 GMT >>> Have you tried placing a new entry in the table that logs to a text file >>> or sends an email at regular intervals to see if that task fails as well? [quoted text clipped - 16 lines] > well. It seems only to affect user's crontabs, but I am the only user > using cron so it may actually be specific to mine. Try to make your jobs have fewer external dependencies, like email and your LineCal script, and get them to write their output to files instead. Maybe your failures are in the dependencies.
Cheers,
Chris
Robert Peirce - 23 May 2008 00:03 GMT > Try to make your jobs have fewer external dependencies, like email and > your LineCal script, and get them to write their output to files > instead. Maybe your failures are in the dependencies. I would agree if it never worked. However, it does work after every time I edit the file but eventually fails if I have not edited the file. So, it is not cron or LineCal, per se. It is something that happens to cron when crontab doesn't get changed for a while.
It is bizarre. I don't see it on my 10.4.11 machine at home, just on the 10.5.2 server at the office. Interesting thought, my wife's machine runs 10.5.2 client. I will have to see what happens on it. I will have it email me a test message every two hours and see what happens after a couple of days.
 Signature Robert B. Peirce, Venetia, PA 724-941-6883 bob AT peirce-family.com [Mac] rbp AT cooksonpeirce.com [Office]
Chris Ridd - 23 May 2008 07:12 GMT >> Try to make your jobs have fewer external dependencies, like email and >> your LineCal script, and get them to write their output to files [quoted text clipped - 4 lines] > So, it is not cron or LineCal, per se. It is something that happens to > cron when crontab doesn't get changed for a while. Maybe, though I would strongly recommend removing those dependencies for a while just to see. It can't hurt, can it?
Cheers,
Chris
Jolly Roger - 22 May 2008 21:08 GMT > > > > > Did you sleep the computer last night? When the computer is asleep > > > > > *nothing* runs. [quoted text clipped - 23 lines] > time, possibly a day. Editing the file with crontab -e seems to cause > cron to look at it for at least the next day. Beyond that it gets iffy. I suggest rather than doing it once a minute, doing it at the exact same interval as the problem entry.
 Signature Please send all responses to the relevant news group. E-mail sent to this address may be devoured by my very hungry SPAM filter. I do not read posts from Google Groups. Use a real news reader if you want me to see your posts.
JR
Jolly Roger - 21 May 2008 15:11 GMT > > > Did you sleep the computer last night? When the computer is asleep > > > *nothing* runs. [quoted text clipped - 11 lines] > edited. Does it ever read it again? Maybe I could have root's tab > touch the file once a day! Do me a favor: Do a 'crontab -l', then copy the output into a reply here.
 Signature Please send all responses to the relevant news group. E-mail sent to this address may be devoured by my very hungry SPAM filter. I do not read posts from Google Groups. Use a real news reader if you want me to see your posts.
JR
Robert Peirce - 22 May 2008 15:19 GMT > > > > Did you sleep the computer last night? When the computer is asleep > > > > *nothing* runs. [quoted text clipped - 13 lines] > > Do me a favor: Do a 'crontab -l', then copy the output into a reply here. $ cat cl.out # MIN HOUR DAY/MONTH MONTH DAY/WEEK COMMAND 05 04 * * 1-4 /usr/local/sh/LineCal "/Users/rbp/.MyCal -A -1" rbp 05 04 * * 5 /usr/local/sh/LineCal "/Users/rbp/.MyCal" rbp
LineCal is a script that runs calendar on a file and mails the output one line at a time. Since the first arg is applied to calendar, I was able to slip "-A -1" into it to just get today's calendar during the week.
 Signature Robert B. Peirce, Venetia, PA 724-941-6883 bob AT peirce-family.com [Mac] rbp AT cooksonpeirce.com [Office]
Jolly Roger - 22 May 2008 21:11 GMT > > Do me a favor: Do a 'crontab -l', then copy the output into a reply here. > [quoted text clipped - 7 lines] > able to slip "-A -1" into it to just get today's calendar during the > week. I would add this to the end of each one:
05 04 * * 1-4 /usr/local/sh/LineCal "/Users/rbp/.MyCal -A -1" rbp > /path/to/log/file 2>&1
05 04 * * 5 /usr/local/sh/LineCal "/Users/rbp/.MyCal" rbp > /path/to/log/file 2>&1
Also, like I said in another post, add an entry at the same time as the problem entry for debugging purposes. What we want to find out is if multiple entries for that same time don't run, or if only one of them doesn't run.
 Signature Please send all responses to the relevant news group. E-mail sent to this address may be devoured by my very hungry SPAM filter. I do not read posts from Google Groups. Use a real news reader if you want me to see your posts.
JR
Jolly Roger - 22 May 2008 21:44 GMT > I would add this to the end of each one: > [quoted text clipped - 3 lines] > 05 04 * * 5 /usr/local/sh/LineCal "/Users/rbp/.MyCal" rbp > > /path/to/log/file 2>&1 I should be more clear about the log file. This is a path of your choosing, and the file does not have to exist. Note that cron will need permission to create and write to the file, though. So make sure the path points to a location where the current user has write access.
 Signature Please send all responses to the relevant news group. E-mail sent to this address may be devoured by my very hungry SPAM filter. I do not read posts from Google Groups. Use a real news reader if you want me to see your posts.
JR
Robert Peirce - 22 May 2008 23:52 GMT > > > Do me a favor: Do a 'crontab -l', then copy the output into a reply here. > > [quoted text clipped - 20 lines] > multiple entries for that same time don't run, or if only one of them > doesn't run. I used the "2>&1 | mailx -s cron rbp" trick. It sends mail when the job runs but not when it doesn't. However, system.log records an error message when cron runs a job and it duplicated the mail message so I removed mail.
I will add an entry to run at the same time, but I have to wait until tomorrow. It seems to work when I edit the file so I need to wait until it doesn't work again.
Also, at Apple's direction I just added "-x ext,load" to the launch daemon for cron. This isn't in my man page for 10.4.11, so I am not 100% sure what it does, but I think it puts something in system.log every time a job loads. Of course, if the job doesn't get run it may not get loaded either. I'll have to wait to see the output tomorrow.
 Signature Robert B. Peirce, Venetia, PA 724-941-6883 bob AT peirce-family.com [Mac] rbp AT cooksonpeirce.com [Office]
Bob Harris - 23 May 2008 01:17 GMT > > > > > Did you sleep the computer last night? When the computer is asleep > > > > > *nothing* runs. [quoted text clipped - 24 lines] > able to slip "-A -1" into it to just get today's calendar during the > week. Is there really a file with the name
".MyCal -A -1"
Or are -A and -1 arguments to .MyCal ? If they are arguments, then the way you have specified the Mon-Fri jobs will not find the file because it is looking for ".MyCal -A -1" instead of .MyCal
Is ".MyCal -A -1" executable? Is .MyCal executable?
Are these 2 files scripts? If so, what scripting language are they?
If they are scripts, then is the first line of the scripts #!/path/to/shell for example: #!/bin/sh #!/bin/bash #!/usr/bin/perl #!/usr/bin/python #!/usr/bin/ruby etc...
If they are scripts, do the scripts depend on finding executables in your normal interactive PATH? Keep in mind that the cron PATH looks like this: PATH=/usr/bin:/bin
In fact the environment variables you get in cron are: SHELL=/bin/sh USER=your_username PATH=/usr/bin:/bin PWD=/Users/your_home_directory SHLVL=1 HOME=/Users/your_home_directory LOGNAME=your_username
If your script depends on additional environment variables, they may not be there.
Bob Harris
Robert Peirce - 24 May 2008 04:43 GMT > Is there really a file with the name > > ".MyCal -A -1" No. The file is MyCal. It is an arg to calendar. It turns out that feeding calendar -f "/Users/rbp/.MyCal -A -1" is treated the same as calendar -f /Users/rbp/.MyCal -A -1. It is a trick I discovered in the script.
 Signature Robert B. Peirce, Venetia, PA 724-941-6883 bob AT peirce-family.com [Mac] rbp AT cooksonpeirce.com [Office]
Bob Harris - 24 May 2008 15:00 GMT > > Is there really a file with the name > > [quoted text clipped - 4 lines] > calendar -f /Users/rbp/.MyCal -A -1. It is a trick I discovered in the > script. Yes, but in cron "/Users/rbp/.MyCal -A -1" is used as
/bin/sh "/Users/rbp/.MyCal -A -1" ...
where the entire quoted string is looked up as the executable file. Since "/Users/rbp/.MyCal -A -1" as a file does not exist, the /bin/sh command fails, and your crontab entry does not run.
This explains the problem with your crontab entry.
Bob Harris
Robert Peirce - 24 May 2008 23:36 GMT > > > Is there really a file with the name > > > [quoted text clipped - 12 lines] > file. Since "/Users/rbp/.MyCal -A -1" as a file does not exist, > the /bin/sh command fails, and your crontab entry does not run. Except the entire entry is
05 04 * * 1-4 /usr/local/sh/LineCal "/Users/rbp/.MyCal -A -1" rbp
which feeds two arguments to LineCal. LineCal contains the code
calendar -f $1, which becomes calendar -f /Users/rbp/.MyCal -A -1
This actually works if the crontab gets called; I have confirmed that. The problem I have is that it sometimes doesn't get called. I would have the same problem if I had
05 04 * * 1-4 mailx -s Test rbp
That also works if the crontab gets called, but not if it doesn't.
 Signature Robert B. Peirce, Venetia, PA 724-941-6883 bob AT peirce-family.com [Mac] rbp AT cooksonpeirce.com [Office]
Jolly Roger - 25 May 2008 02:10 GMT > 05 04 * * 1-4 /usr/local/sh/LineCal "/Users/rbp/.MyCal -A -1" rbp > > which feeds two arguments to LineCal. LineCal contains the code > > calendar -f $1, which becomes calendar -f /Users/rbp/.MyCal -A -1 So why wouldn't you just do:
05 04 * * 1-4 /usr/local/sh/LineCal "/Users/rbp/.MyCal
And:
calendar -f $1 -A -1
 Signature Please send all responses to the relevant news group. E-mail sent to this address may be devoured by my very hungry SPAM filter. I do not read posts from Google Groups. Use a real news reader if you want me to see your posts.
JR
Robert Peirce - 25 May 2008 22:02 GMT > > 05 04 * * 1-4 /usr/local/sh/LineCal "/Users/rbp/.MyCal -A -1" rbp > > [quoted text clipped - 9 lines] > > calendar -f $1 -A -1 Because I only do this on 1-4. On 5 I drop the -A -1 so I can see any weekend items. I tried to just get Friday, Saturday and Sunday but couldn't come up with the right arg, so I just do the whole thing. It is easier that way.
 Signature Robert B. Peirce, Venetia, PA 724-941-6883 bob AT peirce-family.com [Mac] rbp AT cooksonpeirce.com [Office]
Jolly Roger - 25 May 2008 22:15 GMT > > > 05 04 * * 1-4 /usr/local/sh/LineCal "/Users/rbp/.MyCal -A -1" rbp > > > [quoted text clipped - 14 lines] > couldn't come up with the right arg, so I just do the whole thing. It > is easier that way. You're just adding unnecessary confusion. There's no need for the LineCal script. Why not do:
05 04 * * 1-4 /usr/bin/calendar -f /Users/rbp/.MyCal -A -1 rbp 05 04 * * 5 /usr/bin/calendar -f /Users/rbp/.MyCal" rbp
What's this "rbp" supposed to be, anyway? Is that where the output of calendar is supposed to go?
Why would you run 'calendar' every day like this to begin with? How do you access the output?
 Signature Please send all responses to the relevant news group. E-mail sent to this address may be devoured by my very hungry SPAM filter. I do not read posts from Google Groups. Use a real news reader if you want me to see your posts.
JR
Robert Peirce - 26 May 2008 00:06 GMT > You're just adding unnecessary confusion. There's no need for the > LineCal script. Why not do: [quoted text clipped - 7 lines] > Why would you run 'calendar' every day like this to begin with? How do > you access the output? LineCal takes the output from calendar and mails it one line at a time to rbp [me]. The subject is the individual calendar reminder. This is the way pre-Apple calendar worked on our machine. Then, when I receive mail that the item is done I just delete that reminder.
The alternate is to edit the normal Apple calendar output as each item is completed [which Microsoft Outlook allows me to do], but then I have to look at the contents of the mail to see what items are not complete. It is also difficult to prepare a list of outstanding items for our weekly meetings.
It is a convenience when all of the reminders have to do with things I need to be sure other people have done. I just select all the reminders and drag them to a "waiting" folder until each is completed. I run it every day because there is a different list of things to do every day. I have four people reporting to me and need to be sure the important daily tasks are getting done. Outlook allows me to print a subject list which I can copy and distribute when we meet.
There are other ways to do this, but this is what we did before adding the appleserver. After trying the way Apple calendar sends reminders, all in one mail item, I decided I preferred the way we did it before, and I wrote LineCal.
 Signature Robert B. Peirce, Venetia, PA 724-941-6883 bob AT peirce-family.com [Mac] rbp AT cooksonpeirce.com [Office]
|
|
|