Cron execution of shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cron execution of shell script
# 1  
Old 09-08-2008
Cron execution of shell script

Hi Guys,
Unable to run this script from the cron,although the same executes perfectly from the command line.Please help.


#!/bin/sh

#### aprintd alarm creation files #####

file=`date +%m%d%Y`
pid=$$
echo "$pid"
/u01/app/netboss/bin/aprintd/aprintd > $file &
childpid=$!
echo "$childpid"
while .
do

time=`date +%H%M%S`
if [ $time -eq 050000 ]
then
kill $childpid
echo "if loop"
kill $pid
fi
done
# 2  
Old 09-08-2008
Hi there...

Normally when you can't execute a script in cron and manually ok the problem is the envroment variables....

Try to insert in the script:
export PATH=.........

or if .profile has the correct PATH execute it in the script.
# 3  
Old 09-08-2008
I think you meant while :, not while .?
# 4  
Old 09-08-2008
Btw: There is a search function here in the forum and if you use patterns like "cron" and "script" you get a lot of close hits. Also if you have errors to show us, please post them too.


Source your neeed environment files like for example ".profile" in the head of the script because when it's running under cron, they will not be used automatically. Also you might use absolute paths if something is not found.

Example:
Code:
. ~myuser/.profile
...yourscript comes here....

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Execution problem with Cron: Script works manually but not w/Cron. Why?

Hello gurus, I am making what I think is a simple db2 call from within a shell script but I am having difficulty producing the desired report when I run the script shown below from a shell script in cron. For example, my script and the crontab file setup is shown below: #!/bin/ksh db2... (3 Replies)
Discussion started by: okonita
3 Replies

2. Solaris

Script on Solaris spawning 2 processes for one shell script execution

Hi, I am having a shell script on Solaris 10 which has a while loop as shown below. #!/usr/bin/ksh # while do sleep 60 done Name of the shell script is coldcentric.sh. I executed script /DATAWAREHOUSE/LOAD/Scripts/coldcentric.sh from a command task in Informatica worklow as... (3 Replies)
Discussion started by: chekusi
3 Replies

3. Shell Programming and Scripting

Shell Script execution issues

Hi, There's a shell script by name "download", which has been created as user "mgr" and that script needs to executed as user "dev". I tried giving privileges 701 on the script download. But it's throwing the error message bin]$ ./download /bin/bash: ./download: Permission denied ... (6 Replies)
Discussion started by: venkatesh17
6 Replies

4. UNIX for Dummies Questions & Answers

shell script execution in ab initio

Hi All, How to execute shell script for running Ab initio graphs? Regards (0 Replies)
Discussion started by: eshalife
0 Replies

5. UNIX for Advanced & Expert Users

SSH using shell script terminates the script execution

Hello, I am writing a shell script in which i do ssh to remote server and count the number of files there and then exit. After the exit the shell script terminates which i believe is expected behavior. Can some one suggest me a way where even after the exit the script execution resumes. ... (2 Replies)
Discussion started by: manaankit
2 Replies

6. UNIX for Dummies Questions & Answers

Mac OSX Cron Script Execution

Hello, On Mac OSX, I was wondering about my Cron Script: HELL=/bin/tcsh PATH=/sbin:/bin:/usr/sbin:/usr/bin HOME=/var/log MAILTO=jwillis 25 1 * * * root /Users/jwillis/Fbcmd\Scripts/DailyBirthday.scrmy returned message is: Subject: Cron... (3 Replies)
Discussion started by: jwillis0720
3 Replies

7. Shell Programming and Scripting

script execution differs in cron

I have the following script (MyScript): #!/bin/sh ps U erv | grep -v grep | grep -F "/usr/bin/collect -o 101" echo "Result: $?" When executed from the command line, I get ... (the line containing /usr/bin/collect -o 101) Result: 0 (which is correct since collect is running) When I... (4 Replies)
Discussion started by: lost_neko
4 Replies

8. Shell Programming and Scripting

automatic execution of shell script

Dear All, I want to execute a shell script,whlie system is booting. I was try using /etc/rc.d/rc.local file but its not working. (1 Reply)
Discussion started by: rajamohan
1 Replies

9. UNIX for Dummies Questions & Answers

Is there a way to tell how long does a shell script's execution take?

Is there a way to tell how long does a shell script(or a shell command)'s execution take? (4 Replies)
Discussion started by: meili100
4 Replies

10. Shell Programming and Scripting

execution of shell script

How can I execute another shell script from one? Malay (5 Replies)
Discussion started by: malaymaru
5 Replies
Login or Register to Ask a Question