|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Perl script as cron job
I just need to have a perl script executed by crond every 10 minutes. I already made the according entry in crontab and checked via /var/log/cron if the script gets called. Although the script is called by cron, it does simply nothing. It just seems like the script terminates right at the first line. Can anybody help?
![]() |
|
#2
|
|||
|
|||
|
It would help if you told us what it did or showed some source code.
One thing you might also make sure of is that it has permissions to run (that is, 'chmod 755' most of the time). Also make sure that the file contains to windows \r's (happens when you upload an ascii file in binary format).
__________________
Jon Coulter ledjon@ledjon.com |
|
#3
|
|||
|
|||
|
tracked it down..
All right, I've been able to figure it out myself: It just looked like the perl script terminated but that wasn't the case.
The script is located in a certain directory together with a log file that it writes to (at least supposed to). In order to figure out what the error was, I put a log write as the first line of the script - but it never wrote a single line to the log file (located in the same dir), so I thought the script wasn't executed. I learned that I have to use the full path for the log file in order to make the script find it - although located in just the same dir. I just wonder what the base dir with a cron call is if not the dir where the script itself is located? ![]() |
|
#4
|
|||
|
|||
|
I believe the home directory of the user that is running it, but I could be wrong.
|
|
#5
|
|||
|
|||
|
>> make sure of is that it has permissions to run (that is, 'chmod 755' most of the time)
That's extremely insecure, don't even do it. Just chmod it 700 since it's to be executed as the same user in a cron environment anyway. >> I just wonder what the base dir with a cron call It could be anywhere and it doesn't matter so long as the cron of that user has execute permission to that script in that directory. |
|
#6
|
|||
|
|||
|
Well the first part is obviously true, but I was saying it needed those permissions for testing (to make sure that wasn't the problem).
The second part isn't what i means at all. He means that if he called: open(BLAH, ">file.txt"); What directory file.txt would be created in. |
|
#7
|
|||
|
|||
|
>> that is, 'chmod 755' most of the time
We know it's a cron environment, there is just no need to chmod 755 for testing. most of the time means you are supposed to chmod 755 your script in a cron environment in most case. In Apache, yes, you chmod your scripts to 755 most of the time because most people run Apache as nobody user. >> but I was saying it needed those permissions for testing Testing what? It's too late to defend your wrong + insecure suggestion. Just chmod 700, that's all and it's that simple. |
|
#8
|
|||
|
|||
|
[ bah, I don't know why i'm even arguing this point. Your right for this example anyway (even though there are cases where my method would be better) ]. You need to stop being such a negative f**k face to everybody all the time.
I also like how you didn't comment about the 2nd part where you obviously know you were wrong. |
|
#9
|
|||
|
|||
|
>> you are guessing that he is going to be the only person executing this
He said his perl script is to be executed from a cronjob every 10 minutes. Why in the world does it need execute permission to everybody? Right, we are both guessing, but your guess (from changing the original subject in purpose to defend your wrong suggestion) is obviously not making sense. When you are running a script every 10 minutes, why in the world should someone interference with it? That's why that your suggestion was wrong and that's why my guess is wiser comparing to yours. >> You need to stop being such a negative f**k face to everybody all the time. Not to everybody but only to those who posts something wrong + insecure - that was you. I know you never admit fault and you think you are always right. Oh, I am wrong, I am not supposed to make a Perl master like you to get embarrass in this forum just because you posted something wrong. >> you didn't comment about the 2nd part I didn't continue to the 2nd part because you thought the same I believe the home directory of the user that is running it and HOME is where it's and that answer was absolutely correct. I realized I misunderstood his question just like you did earlier. I thought he was asking if he must run a script via cronjob within a particular directory like so: 10 * * * * his_perlscript.pl 2>&1 > /dev/null or: 10 * * * * /any/path/to/his_perlscript.pl 2>&1 > /dev/null |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Perl script as cron job |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|