Script behaving differently in Crontab..


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script behaving differently in Crontab..
# 1  
Old 09-29-2004
Script behaving differently in Crontab..

Hi,

I wrote a script to stop a process,truncate its log files and re-start the process...
We are using Progress Software in Unix ( Sun Sparc)

When ever I start this progress program , it should kick off a C pgm in the background..
The script work perfectly fine when I run it from command prompt..
When I scheduled it from crontab, the stopping and truncating log files works fine..
When it starts of the progress program, that time also it looks OK..
But when I do (ps -ef ) for that C program, I found two instances of the C program running.. One is the actual C program which I wanted it to run and other is the same C program with slightly different process name...
> ps -ef | grep 'myprocess'
admin1 .......... myprocess
admin1 .......... usr/bin/sh -C myprocess

Also, the second process is the parent for first process...
Any ideas why it is working differently in crontab ??
If my explanation is not clear, let me know... I could post some screen dumps which might explain more...

Thanks in advance,
# 2  
Old 10-01-2004
crontab runs in sh shell

I believe you are seeing what you are because crontab always (best I can tell runs in sh shell).

Thus it's not 2 processes running it's crontab starting the sh shell,

check who is the parent of:

admin1 .......... usr/bin/sh -C myprocess

and then your script being run in the sh shell:

admin1 .......... myprocess

The crontab scripts I run always do this. The only real problem is when you don't want you script ran in the sh shell. the following line put as the 1st line of your script can change the shell but I find it not an execate science...

#!usr/bin/SHELL_YOU_WNAT_TO_RUN_IN

ps even if you do this you will get the:

admin1 .......... usr/bin/sh -C myprocess
# 3  
Old 10-01-2004
Thanks a lot..
I was under the impression that two instances are running..
looks like it is not..
should be OK to run sh shell itself...
# 4  
Old 10-01-2004
Please navigate:
www.unix.com home page -> Answers to Frequently Asked Questions -> cron and crontab

and scroll down to: It works from the command line but not in crontab
# 5  
Old 10-01-2004
Yeah.
After seeing your reply on other forum , I checked the posting "Cron and Crontab" and it helped me a lot..

If the process did not run from crontab, I would have thought it has something to do with environment variables or shell..
In my case, I was seeing two listings of same processes when I run it from Crontab.. Now, it is clear that one is not actually a process ( just kicked off by cron)..

Anyways, Thanks for the help and I'll make sure to follow the forum rules...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk script modification - treat certain files differently

awk 'BEGIN{OFS=","} FNR == 1 {if (NR > 1) {print fn,fnr,nl} fn=FILENAME; fnr = 1; nl = 0} {fnr = FNR} /UNUSUAL/ && /\.gz/ ~ /FILENAME/ {nl++} <'{system ("gunzip -cd FILENAME")}' END ... (2 Replies)
Discussion started by: SkySmart
2 Replies

2. Filesystems, Disks and Memory

Different partitions of a drive behaving differently in Windows

I have a memory card of my Nokia N73 attached to laptop. There are a few partitions. Why all partitions behave differently? As clear from the attachments, for some partition, delete option is disabled. See 'Disk 1' which is my memory card. Here, patition 'G' (CHECK), i created in windows. The... (6 Replies)
Discussion started by: ravisingh
6 Replies

3. Shell Programming and Scripting

Same KSH behaving differently on diff servers

HI all I have written a ksh to execute PL/sql procedure and generate the log file. The script is working fine to the extent of calling the taking input, executing PL/SQL procedure. On one server the log file is getting generated properly. i,e it shows the DBMS output . The log file size was... (9 Replies)
Discussion started by: ramakrishnakini
9 Replies

4. Shell Programming and Scripting

jobs command behaving differently in script

Here is my test script: #!/bin/sh result=`jobs` echo " Jobs: "$result result=`ls` echo " LS "$result Here is the output: Jobs: LS 0 1 2 3 4 5 6 7 gcd initialize.sh #inter_round_clean.sh# inter_round_clean.sh inter_round_clean.sh~ look parallel_first_run.sh... (3 Replies)
Discussion started by: nealh
3 Replies

5. Shell Programming and Scripting

Executing a script from CRON behaves differently than terminal

Hi have a script which transferers from Microsoft server to Linux box. The scripts(ksh) is on Linux box. If I run script from terminal, it transfers files to directory. Where as If I run script from CRON. It does not. Here is the log of both: Terminal execution log:... (2 Replies)
Discussion started by: dipeshvshah
2 Replies

6. Shell Programming and Scripting

sed and cut behaving differently

I have attached a file with few records. First 2 characters of each record are binary characters. I can remove it by and it works fine. But is behaving differently and removing more than expected characters. Can someone help me in accomplishing it through sed? Thanks in advance. (13 Replies)
Discussion started by: amicon007
13 Replies

7. UNIX for Advanced & Expert Users

Unix script rm behaiving differently in difference machine

Hi All The below is the script, if i supply the script with the argument -f then it will delete the tmp file . We are having 3 unix system out of that two system are processing this file only one system is not processing and the error showin is below the script .. can you please help me ... (2 Replies)
Discussion started by: arunkumar_mca
2 Replies

8. Shell Programming and Scripting

Why is a variable behaving differently in ksh script.

Guys i have strange behaviour with command output being saved in a variable instead of a tmp file. 1. I suck command output into a variable Sample command output # cleanstats DRIVE INFO: ---------- Drv Type Mount Time Frequency Last Cleaned Comment *** ****... (1 Reply)
Discussion started by: lavascript
1 Replies

9. UNIX for Advanced & Expert Users

Script behaving differently on two servers

All, I have a script that runs on 2 servers and there seems to be something wrong. It's producing different results on the 2 servers. Here is the script on server1 which is behaving correctly but on 2 behaving differently. 2nd server: I couldn't make out whats the error is?... (5 Replies)
Discussion started by: mhssatya
5 Replies

10. UNIX for Advanced & Expert Users

Script behaving differently in Crontab..

I posted this in Shell scripting... maybe I'll try it in this forum.. ***************** I wrote a script to stop a process,truncate its log files and re-start the process... We are using Progress Software in Unix ( Sun Sparc) When ever I start this progress program , it should kick off a... (1 Reply)
Discussion started by: newtoxinu
1 Replies
Login or Register to Ask a Question