Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 10th, 2001, 10:30 AM
herou herou is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Location: germany
Posts: 119 herou User rank is Corporal (100 - 500 Reputation Level)herou User rank is Corporal (100 - 500 Reputation Level)herou User rank is Corporal (100 - 500 Reputation Level)herou User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 11 h 26 m 4 sec
Reputation Power: 12
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?

Reply With Quote
  #2  
Old July 10th, 2001, 11:18 AM
JonLed JonLed is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Indiana
Posts: 614 JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 10
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

Reply With Quote
  #3  
Old July 10th, 2001, 03:08 PM
herou herou is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Location: germany
Posts: 119 herou User rank is Corporal (100 - 500 Reputation Level)herou User rank is Corporal (100 - 500 Reputation Level)herou User rank is Corporal (100 - 500 Reputation Level)herou User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 11 h 26 m 4 sec
Reputation Power: 12
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?


Reply With Quote
  #4  
Old July 10th, 2001, 04:30 PM
JonLed JonLed is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Indiana
Posts: 614 JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 10
I believe the home directory of the user that is running it, but I could be wrong.

Reply With Quote
  #5  
Old July 11th, 2001, 12:30 AM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> 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.

Reply With Quote
  #6  
Old July 11th, 2001, 01:14 AM
JonLed JonLed is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Indiana
Posts: 614 JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 10
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.

Reply With Quote
  #7  
Old July 11th, 2001, 01:49 AM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> 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.

Reply With Quote
  #8  
Old July 11th, 2001, 01:52 AM
JonLed JonLed is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Indiana
Posts: 614 JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 10
[ 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.

Reply With Quote
  #9  
Old July 11th, 2001, 02:27 AM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> 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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Perl script as cron job


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate 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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway