Crontab a Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Crontab a Script
# 1  
Old 01-16-2008
Crontab a Script

I know my question maybe eazy, but it realy cause a problem for me

I have a Perl script to run and get some output, I run this script using perl /moutaz/ciscolog/telnet.pl

I made another script as followSmilie/moutaz/ciscolog/script)
#!/bin/bash
perl /moutaz/ciscolog/telnet.pl
cp /moutaz/ciscolog/ciscolog /moutaz/ciscolog/ciscolog-$(date'+%H-%M')-$RANDOM

Then made crontab as follow:
15 * * * * /moutaz/ciscolog/script

The question:
-when apply command from shell it worked fine.
- from crontab it doesn't, only the cp command work.

what is the problem?
# 2  
Old 01-16-2008
May it was not able to find the Perl executable path.
Can you try the same by giving the full path to perl in your script?

Thanks
Nagarajan G
# 3  
Old 01-16-2008
Thanks for your reply.

But it is exactly what I did.

In script which run from crontab: perl /moutaz/ciscolog/telnet.pl
Also in cron tab /moutaz/ciscolog/script

Even I tried to put in Cron perl /moutaz/ciscolog/telnet.pl it doesn't work

It is weird, I don't know what is the issue.
# 4  
Old 01-16-2008
You need to put the full path to the Perl interpreter not just your script. You probably want:

/usr/bin/perl /moutaz/ciscolog/telnet.pl

in the script.
# 5  
Old 01-16-2008
Unfortunantely, It also didn't work also.
# 6  
Old 01-16-2008
Quote:
Originally Posted by moutaz1983
I know my question maybe eazy, but it realy cause a problem for me

I have a Perl script to run and get some output, I run this script using perl /moutaz/ciscolog/telnet.pl

I made another script as followSmilie/moutaz/ciscolog/script)
#!/bin/bash
perl /moutaz/ciscolog/telnet.pl
cp /moutaz/ciscolog/ciscolog /moutaz/ciscolog/ciscolog-$(date'+%H-%M')-$RANDOM

Then made crontab as follow:
15 * * * * /moutaz/ciscolog/script

The question:
-when apply command from shell it worked fine.
- from crontab it doesn't, only the cp command work.

what is the problem?

Why dont you try redirecting the cron output to some log file
Code:
 15 * * * * /moutaz/ciscolog/script >> /tmp/cron.log 2>&1

If in the perl script ( /moutaz/ciscolog/telnet.pl ) you may have used the perl instead of full path to perl,try that too

Thanks
Nagarajan G
# 7  
Old 01-16-2008
Yes, It helped alot.

The error file contain the following:

Can't locate Net/Telnet.pm in @INC (@INC contains: /usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl5/5.8.5 /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4 /usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2 /usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at /moutaz/ciscolog3/telnet.pl line 4.
BEGIN failed--compilation aborted at /moutaz/ciscolog3/telnet.pl line 4.

I think this will limit the problem.

The perl script is using Net::Telnet to make telnet to routers, So what do you think the problem?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Crontab in script

I have crontab setup via crontab -e I was wondering if its possible to create a cron job from a script so when the script is run the cron job is created? (3 Replies)
Discussion started by: scriptnewbie
3 Replies

2. UNIX for Dummies Questions & Answers

crontab not running script

Hi All, I am having the below script to be run from crontab, it it doesnt run. 1 * * * * /home/cobr_ext/test.sh > /home/cobr_ext/temp.txt when i run i manally it runs without any issues. Could please help me as to why doesnt it run the script.:( (7 Replies)
Discussion started by: abhi_123
7 Replies

3. UNIX for Dummies Questions & Answers

Crontab + Script + .sql

Hi guys today i'll bring to you a new problem that i need to execute. So what i need to do it's create a script that: conect to some database logon run a .sql script logoff and close the connection after that, put this script on the crontab To set up the crontab it's ok for me, i think... (3 Replies)
Discussion started by: Newer
3 Replies

4. UNIX for Dummies Questions & Answers

crontab script

Hi guys Can someone help me with a crontab script please? I have to sort the files from /bin and put the first 3 of then (with size and path) in /home/user/bin_size i write the command: find /bin/ | xargs ls -lS | awk 'FNR<4{print($5, $9)}' > /home/user/bin_size which is working but when... (6 Replies)
Discussion started by: G30
6 Replies

5. UNIX for Dummies Questions & Answers

crontab script

Hi guys Can someone help me with a crontab script please? I have to sort the files from /bin and put the first 3 of then (with size and path) in /home/user/bin_size i write the command: find /bin/ | xargs ls -lS | awk 'FNR<4{print($5, $9)}' > /home/user/bin_size which is working but when I... (2 Replies)
Discussion started by: G30
2 Replies

6. Shell Programming and Scripting

crontab script

Hi All, I am running a script to find the CPU and memory utilization of the server. Script name is atul. When i run this script then it gives the desired output as DATE, CPU and MEMORY utilization....as mentioned below: $ $ cat atul A=`date| cut -d" " -f1-4; top -d 1 -n 1 | awk '/^CPU... (5 Replies)
Discussion started by: atulbassi83
5 Replies

7. Solaris

pl script in crontab

Hi I have successfukky created a sh script that runs perfectly well when run. It contains within a pl script that when run through a crontab will not run. Are there restrictions running a pl in cron? (14 Replies)
Discussion started by: rob171171
14 Replies

8. Shell Programming and Scripting

How to add a script to Crontab?

Hi! We are on AIX 5.3 I have a script that must be run once every hour. How do i add this to the crontab? I know how to access crontab which is, crontab -e. What do i do after that ? If i have the path to the script? Thank you!!! (4 Replies)
Discussion started by: atechcorp
4 Replies

9. UNIX for Dummies Questions & Answers

Using a script to modify the crontab

I want to add one line to the end of my crontab using a script. I have tried piping in the editor commands, but I can't get it to work. crontab -e user << EX $a This is the text I want to add. . wq EX This doesn't work. Is there an easier way to do this? (2 Replies)
Discussion started by: johnmsucpe
2 Replies

10. Shell Programming and Scripting

how can i use crontab in a script?

hi.. i wolud like to know if itīs possible use the crontab command in my script. the idea is what the script starts automatically, but i donīt know how to do it. please, help me.... thanks jonathan (1 Reply)
Discussion started by: DebianJ
1 Replies
Login or Register to Ask a Question