karlgoethebier has asked for the wisdom of the Perl Monks concerning the following question:
Hi all, this is an old story, but it's still sometimes surprising:
The task
- On a machine some files are uploaded via SFTP for further processing
- Search for some files with a given name pattern and suffix (xml)
- If the last file uploaded with name/suffix is older than n hours then send an email to customer and write the disaster to syslog
- Write a status file (e.g. containing 0/1) to /tmp for each disaster found for Nagios monitoring via SSH
What i did
I wrote some perl....
disaster.pl --foo bar...and a shell wrapper for cron:
#!/bin/bash /usr/local/bin/disaster.pl --foo bar > /dev/null 2>&1
The scenario
I've got a test machine and a production machine which are totally identical.
It is impossible to test on prod.
OS is SLES11.
The observation
Running the perl script as well as the shell wrapper via commandline or cron on test leads to the expected results.
The UID on test is root.
On prod the UID is another, let's say karl - for some reason.
On prod the cron job (shell wrapper) gets executed and cron writes this to syslog but the perl script doesn't write to syslog and doesn't mail.
But when i change the shell wrapper on prod to...
/usr/bin/perl /usr/local/bin/disaster.pl --foo bar > /dev/null 2>&1...it works.
The question
But why - what do i miss?
N.B.: Perl code, shell wrapper and crontab are OK, that's why i didn't post more details.
Update:
I tried all the given hints (most of them i did before posting) but i couldn't figure out the reason for this issue.
But fortunately i had solution: adding /usr/bin/perl in the shell wrapper did the job, although /usr/bin is already in the path when cron runs the script under my uid.
Thanks to all that helped.
Thanks for any hint and Best regards, Karl
|
---|