pl script in crontab


 
Thread Tools Search this Thread
Operating Systems Solaris pl script in crontab
# 8  
Old 03-24-2011
Thanks methyl

Unfortunatel y I do not have root to this server but ovioulsy have rights to run cron under my profile.
How do I locate cron records?
# 9  
Old 03-24-2011
Quote:
Originally Posted by bluescreen
No. If the script will run from the command line, it will run in cron.
That's somewhat optimistic. There are plenty of reasons for a script that runs fine on the command line to fail in cron if not modified. Some of them are:
  • an improperly set PATH. Any script run through cron that use commands located outside of /bin, /usr/bin should have its PATH set inside it.
  • other required environment variables unset. The user's dot files like .profile are not read by cron.
  • resources required unavailable (eg. an X11 server)
  • A tty expected, cron jobs aren't connected to a terminal.
# 10  
Old 03-24-2011
Initial script only had path #!/usr/bin/sh and does refer to a .pl script.
I have amedned now to have two paths with

#!/usr/bin/sh [At the start as normal]

&

#!/usr/bin/perl -w [before perl script is run]

This had no affect and the cron still does not run the script..
# 11  
Old 03-24-2011
There is more information in the parallel post from the same original poster.
https://www.unix.com/shell-programmin...-script-2.html
# 12  
Old 03-24-2011
Quote:
Originally Posted by rob171171
Initial script only had path #!/usr/bin/sh and does refer to a .pl script.
I have amedned now to have two paths with

#!/usr/bin/sh [At the start as normal]

&

#!/usr/bin/perl -w [before perl script is run]

This had no affect and the cron still does not run the script..
Is the /usr/bin/sh script calling the /usr/bin/perl script? -OR- is the Perl script embedded in the sh script? If you can run this from the command line and it completes normally, do you have something in your environment (/usr/bin/env) that is not included in your sh script? Check you PATH var and any other vars that are in your environment and not in your sh script.

HTH
This User Gave Thanks to bluescreen For This Post:
# 13  
Old 03-25-2011
Many thanks bluescreen. How do I check my scipts env?

---------- Post updated at 03:18 AM ---------- Previous update was at 03:13 AM ----------

My env is as such

Code:
alps$ env
TERM=xterm
SHELL=/bin/sh
SSH_CLIENT=172.21.20.206 51860 22
OLDPWD=/home/it/capopt
SSH_TTY=/dev/pts/2
USER=capopt
LD_LIBRARY_PATH=/usr/local/lib:/usr/local/ssl/lib:/usr/local/mysql/lib:/usr/local/mrtg-2/lib:/usr/local/mrtg-2/lib:/usr/share/lib:/usr/openwin/lib:/usr/openwin/platform/sun4u/server/lib:/usr/sadm/lib/smc/lib:/usr/local/lib:/etc/lib:/etc/security/lib:/lib:/opt/SUNWits/Graphics-sw/xil/lib:/usr/sadm/smc/lib:/usr/sadm/lib:/usr/ccs/lib:/usr/openwin/platform/sun4u/server/lib:/oracle_install/product/10.2.0/lib32:/usr/sfw/lib
ORACLE_BASE=/oracle_install
PATH=/usr/bin:
MAIL=/var/mail//capopt
PWD=/home/it/capopt/APNRD/S30
EDITOR=vi
TZ=Eire
ORACLE_TERM=vt100
PS1=alps$
SHLVL=1
HOME=/home/it/capopt
LOGNAME=capopt
VISUAL=vi
SSH_CONNECTION=172.21.20.206 51860 192.168.198.110 22
ORACLE_HOME=/oracle_install/product/10.2.0
_=/usr/bin/env

---------- Post updated at 04:12 AM ---------- Previous update was at 03:18 AM ----------

I think my crons env is as follows as I enabled set >/tmp/mycronenv

Code:
alps$ more mycronenv
HOME=/home/it/capopt
IFS=

LOGNAME=capopt
MAILCHECK=600
OPTIND=1
PATH=/usr/bin:
SHELL=/usr/bin/sh
TZ=Eire

---------- Post updated at 04:56 AM ---------- Previous update was at 04:12 AM ----------

Hi again

i have now incorpotrated all my env vars into the script and through cron it now runs Smilie Smilie Smilie.
What Im not sure about is which vars are actually required to run the script. Do I actually need all of them in there??

Last edited by Franklin52; 03-25-2011 at 07:13 AM.. Reason: Please use code tags
# 14  
Old 03-25-2011
Quote:
Originally Posted by rob171171
What Im not sure about is which vars are actually required to run the script. Do I actually need all of them in there??
Think about what resources your script actually needs to run. I'm sure the PATH (which is the same in both) and LD_LIBRARY_PATH var are probable required. What about the Oracle vars? Does the script need them too? It will just take a bit experimenting by removing some to see of the script runs with out them. If it does, them remove a few more and try it again. Keep doing this until your script will not run if you remove one var. Then you know you've got it! Smilie
This User Gave Thanks to bluescreen For This Post:
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. 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

8. Shell Programming and Scripting

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 follow:(/moutaz/ciscolog/script) #!/bin/bash perl /moutaz/ciscolog/telnet.pl cp... (6 Replies)
Discussion started by: moutaz1983
6 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