cron job is not working for two scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cron job is not working for two scripts
# 1  
Old 04-26-2011
cron job is not working for two scripts

Hi Gurus,

I have a test unix server in which currently some unix cronjob are running.
I have written two script one is a shell script in which env variable are there (in that i am exporting those variables).
I have also written a perl script .

when i am running at the shell manually like below it is working fine.

Code:
.  /dir1/dir2/script.env; /dir1/dir2/script.pl

but when i am running for every minute by the help of cron job.

I mean when i am adding this above job in "crontab -e" like below.

Code:
* * * * *  .  /dir1/dir2/script.env; /dir1/dir2/script.pl

I dont know after every minute i am checking the corresponding log but it seems it is not working.

but when i am adding a job like this
Code:
* * * * * echo hell>>/dir/file1

it is working fine.but dont know why it is not happening in the above perl script case.

Waiting for your reply.

Regards,
Sanjay.
# 2  
Old 04-26-2011
Is it executable chown
with the #! first line pointing at perl?
Does it need a tty?
# 3  
Old 04-26-2011
everything is set properly, it is executable ,#! added for perl ,it does not need tty.

when i told it is working fine at prompt. your questions dont make any sense.

hi gurus please guide me why it is not working.
no luck.

regards,
sanjay
# 4  
Old 04-27-2011
Redirect stdout and stderr from your script to some log file and check once. Possible error might be captured.
# 5  
Old 04-27-2011
hi gurus,

I would like to give more details about the problem how the cronjob is not running.

priviously the cronjob entry was like below

Code:
. /dir1/dir2/cron_test.env;/dir1/dir2/transfer_file_to_target_updatedone.pl

actually in the second file which is perl file the initial lines looked like

Code:
 
#!/opt/perl/bin/perl -I/opt/perl/lib/site_perl -I/opt/perl/lib
use strict;
use Net::SFTP;
use Net::SFTP::Util qw (fx2txt);
use Net::FTP;
use Data::Dumper;
use DBD::Oracle qw(:ora_types);
use MIME::Lite;

But now though we are using the scp to include in the perl file
we are include one module in the perl file (in sence ,we have added a line" use Net::SCP::Expect;"like below) and the current initial lines looks like

Code:
#!/opt/perl/bin/perl -I/opt/perl/lib/site_perl -I/opt/perl/lib
use strict;
use Net::SFTP;
use Net::SFTP::Util qw (fx2txt);
use Net::FTP;
use Net::SCP::Expect; 
use Data::Dumper;
use DBD::Oracle qw(:ora_types);
use MIME::Lite;

and inside the pl we are using scp for secure copy.

now I think i got the problem due to this additional module which we added in the perl script that is making the cron job not running (but first .env script is working in both of cases"as it before and now").

I think some where cron is mainting these modules for "scp"(which should be added in cron list).

I have tried a lot it is not working(as a developer i am not accesed to open cron log) after implemented the "use Net::SCP::Expect; " (think should be added somewhere in cron list which should be done by unix admin).



Waiting for your reply

Sanjay.
# 6  
Old 04-27-2011
First, #! can only have one argument, like "#!/usr/bin/sed -f", see man execvp. Maybe make a shell script wrapper for your perl call, so you can have any command line you want. I get very little use out of anything but #!/usr/bin/ksh or the bash equivalent. I find I can test/enhance better with a wrapper.

Make your cron command log somewhere permanent, so you can see if it has anything to tell you:
Code:
( echo Start CL1 `date` ;  /dir1/dir2/cron_test.env ; echo "Env done, start pl" ;  /dir1/dir2/transfer_file_to_target_updatedone.pl ) >>/var/tmp/cron.log 2>&1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Cron job not working but works on other nodes.

Hi All, I have a many cron jobs scheduled in my AIX server. Only one cron not getting executed in the same server but that job is good on all other servers. Here is my cron , which will keep last 30 files and remove others., 00 00 * * * /usr/bin/find /tmp/reports/nmon -name *.nmon -mtime... (9 Replies)
Discussion started by: Thala
9 Replies

2. UNIX for Dummies Questions & Answers

Cron job not working

cron process in AIX is there when I do ps -ef |grep cron, but none of cron job is working. It appears that cron process is hanging or having some issues? How do you resolve this? Do I kill the cron process by kill -9 PID? and how to start it? Please advise. (1 Reply)
Discussion started by: Daniel Gate
1 Replies

3. UNIX for Dummies Questions & Answers

Executing python scripts via cron job

Hi, I'm executing a python script via cron job. The way it is set up is, I'm editing a file called local00 22 * * * root su - -c "/opt/setup_dir/bin/run_bkp -p" When this job executes, the command-specific logfile and the syslog (where the logs are supposed to go) show half of the logs(no... (2 Replies)
Discussion started by: ashwini.engr07
2 Replies

4. Shell Programming and Scripting

cron job now working?

Hi all, I wrote a script as below, #!/bin/ksh . /app/home/etc/sudo.profile >/dev/null java -jar $HOME/abc.jar The jar file abc.jar is located in the same folder as the script. When I'm manually running that script the jar file gets executed. However if I set a cron job, it... (5 Replies)
Discussion started by: isaacniu
5 Replies

5. Shell Programming and Scripting

Linux - scripts not working in cron

hi all, i have scripts executable in manully, but not working in cron. any ideas? thanks a lot? * * * * * /home/dir/dir/file.sh #! /bin/sh alarmPath="/home/dir/monitoringAlarm" alarmDateTime="$(date +%Y%m%d) $(date +%H%M%S)" tomcatPID=`pidof /usr/local/jdk1.6.0_13/bin/java` echo "tomcat... (3 Replies)
Discussion started by: maxlee24
3 Replies

6. Shell Programming and Scripting

Sudo command not working with cron job.

Hello, I have written a script that has a sudo command to change file permissions within it. When I run the script manually, the sudo command inside of it works fine. When the script is run through crontab I get the error "cron: not found". It the same user profile that I am using... (6 Replies)
Discussion started by: WhotheWhat
6 Replies

7. Shell Programming and Scripting

cron job not working for some reasons

I set up a new cron job. I have set cron jobs many times in the past and never faced issues. For some reasons my new cron job is not working.This is how my cron job looks like. plz help me out guys. 3,8,13,18,23,28,33,38,43,48,53,58 * * * * /siebel/sblp900/home/FSMTaskChk/script... (14 Replies)
Discussion started by: ragha81
14 Replies

8. UNIX for Dummies Questions & Answers

Cron job not working

Hello, I have the following crontab entry that does not seem to be running. When I check /var/cron/log, it is not there. Here is my os info: SunOS birch 5.9 Generic_118558-09 sun4u sparc SUNW,Sun-Fire-V240 Here is the crontab entry: 01 21 * * * find /export/app/datafeed/flus/archive -mtime... (5 Replies)
Discussion started by: dkranes
5 Replies

9. UNIX for Dummies Questions & Answers

CRON job to execute all scripts in a directory

Hi everyone: I'm trying to make a CRON job that will execute Fridays at 7am. I have the following: * 7 * * 5 I've been studying up on CRON and I know to have this in a file and then "crontab filename.txt" to add it to the CRON job list. The CRON part I believe I understand, but I would... (6 Replies)
Discussion started by: Annorax
6 Replies

10. Shell Programming and Scripting

Cron job not working

Hi All, I created a shell script and it works perfectly fine when I run from the command. But the same does not work as expected when I call it from a cron job. Here is the shell script(scan.sh): # # #Which directory to scan for files?... (7 Replies)
Discussion started by: janavenki
7 Replies
Login or Register to Ask a Question