IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Odd cron/links behavior
I've got a PHP script that I copied over from another server. It worked fine there, calling it via 'lynx -dump' from crontab.

The new system didn't have lynx, so I used links instead.

Now I'm getting duplicate execution. I capture the output from the cronjob to a txt file, and that's only showing one instance. But the log file that I write line-by-line within the script shows about 4-7 seconds after the scirpt starts, it starts again.

My suspicion is that the "-dump" option on links is causing it to re-execute so it can grab the output, the way way Firefox often re-executes a page when you try to view source.

Has anyone heard of this problem, or have any other ideas where I should look?

[edit]

links vs. lynx was a red herring. I remembered I had sudo on the box and installed lynx, and that's doing the same thing. This only happens when called via cron, calling the script manually works fine.
--

Drew
Expand Edited by drook Dec. 11, 2009, 05:17:42 PM EST
New I usually use wget for stuff like that.
Regards,
-scott
Welcome to Rivendell, Mr. Anderson.
New How?
I just looked at the man page and didn't see an option to dump output to stdout. Or do you let it keep dropping numbered files, rather than have it write to a logfile?
--

Drew
New cmd >>out.txt file appends output to out.txt
or cmd >outputfile 2>&1
to catch any errors as well
thanx,
bill
New Re: How?
-O file

--output-document=file
The documents will not be written to the appropriate files,
but all will be concatenated together and written to file.
If - is used as file, documents will be printed to standard
output, disabling link conversion. (Use ./- to print to a
file literally named -.)
Regards,
-scott
Welcome to Rivendell, Mr. Anderson.
New Ahh, output-document ... so intuitive
I'll give it a try, but it may not help. I've tried it now with links and lynx, and it does the same thing. Just added logging the pid and creating a lockfile. It's the same process, but for some reason when run via cron it executes the script twice. When I call it manually it just executes once.

Is there a system-level log of what cron executes? What I mean is, aside from the logging that I do myself within the script, is there a log that shows "cron executed script foo at time"?
--

Drew
New typically /var/log/messages and any output is sent to root..
or the user the cron is executed as.
New Nothing in /var/log/messages
But /var/log/auth.log shows cron starting and stopping. For some reason cron runs twice each minute for root.

auth.log:Dec 12 09:14:01 ps17185 CRON[22094]: (pam_unix) session opened for user root by (uid=0)

auth.log:Dec 12 09:14:01 ps17185 CRON[22094]: (pam_unix) session closed for user root
auth.log:Dec 12 09:15:01 ps17185 CRON[22788]: (pam_unix) session opened for user root by (uid=0)
auth.log:Dec 12 09:15:01 ps17185 CRON[22787]: (pam_unix) session opened for user root by (uid=0)
auth.log:Dec 12 09:15:01 ps17185 CRON[22787]: (pam_unix) session closed for user root
auth.log:Dec 12 09:15:01 ps17185 CRON[22792]: (pam_unix) session opened for user drook by (uid=0)
auth.log:Dec 12 09:15:01 ps17185 CRON[22788]: (pam_unix) session closed for user root
auth.log:Dec 12 09:15:04 ps17185 CRON[22792]: (pam_unix) session closed for user drook
auth.log:Dec 12 09:16:01 ps17185 CRON[23731]: (pam_unix) session opened for user root by (uid=0)
auth.log:Dec 12 09:16:01 ps17185 CRON[23731]: (pam_unix) session closed for user root

That shows a single instance of it for my user at 15 after the hour, which is correct. But I still don't trust it. Need to create a copy of the script with heavy debugging in it but not actually send the email and cron that.
--

Drew
New Re: Nothing in /var/log/messages
is a mail server on the machine?

If not check the root user /var/mail/<user>

Any output not redirected by the script is sent to the local user, unless aliases redirect it.
New Nope, not there either
Adding debugging calls now. How tedious ...
--

Drew
New Check /etc/syslog.conf
You can adjust cron logging there. Adding

cron.debug /var/log/cron

will send cron's own debug output to /var/log/cron. Don't forget to recycle the syslog daemon after changing the configuration.
New Good point.
Egads...

debug level wooo

Drew make sure you have your log rotation proper.
New That would do it
Only entries in there for cron right now are
#cron.*       /var/log/cron.log

and
*.=info;*.=notice;*.=warn;\

auth,authpriv.none;\
cron,daemon.none;\
mail,news.none -/var/log/messages

So I'm not getting much info.

Assuming this can throw a huge amount of crap to disk in a hurry, what do I need to do to make sure I don't eat the disk before I can catch it?
--

Drew
New set it for a single pass first, then debug
once you find the issue, then adjust the schedule.
New Figured out the problem ... but not the solution (yet)
I set up the initial crontab, then made one or two changes to it. As a test, I just deleted my crontab, but my job still ran on schedule.

I've got my regular user and an admin user. I've checked that neither of those has a crontab, and I don't see one for root. (Which just means the root user for my virtual server doesn't have one. I don't actually have root on the physical box.)

So, is this something that I can fix, or do I need to submit a ticket to support?
--

Drew
New *NOW* I've figured out the problem ... I am a dumbass
I never disabled the cronjob from the other host. As soon as the DNS changes propagated I started getting two runs. I had assumed since the server still thought it owned the domain that the job would never leave the box, but that doesn't seem to have been the case.
--

Drew
New ICLRPD
*NOW* I've figured out the problem ... I am a dumbass
     Odd cron/links behavior - (drook) - (16)
         I usually use wget for stuff like that. -NT - (malraux) - (12)
             How? - (drook) - (11)
                 cmd >>out.txt file appends output to out.txt - (boxley)
                 Re: How? - (malraux) - (9)
                     Ahh, output-document ... so intuitive - (drook) - (8)
                         typically /var/log/messages and any output is sent to root.. - (folkert) - (7)
                             Nothing in /var/log/messages - (drook) - (6)
                                 Re: Nothing in /var/log/messages - (folkert) - (5)
                                     Nope, not there either - (drook) - (4)
                                         Check /etc/syslog.conf - (scoenye) - (3)
                                             Good point. - (folkert)
                                             That would do it - (drook) - (1)
                                                 set it for a single pass first, then debug - (boxley)
         Figured out the problem ... but not the solution (yet) - (drook) - (2)
             *NOW* I've figured out the problem ... I am a dumbass - (drook) - (1)
                 ICLRPD - (jake123)

It's their own fault! If they wanted to break the law without consequences, they should have gone into banking.
67 ms