- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Cron spawning multiple processes
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-09-2010 04:04 AM
тАО11-09-2010 04:04 AM
Cron spawning multiple processes
I created a very simple ksh script which just writes the current unix time to a file to see if I could eliminate the script itself, however the same problem occurs.
From cron we are also calling a binary executable which reorganises a database. Again, multiple processes are spawned.
I have been seeing this behavior by performing a ps -ef|grep <scriptname> a few times around the time that the crontab starts. Here is an example of the output:
r0_adms 26363 2176 1 14:17:00 ? 0:00 sh -c (. $HOME/set_dmsenv.sh; tb_monitor.sh) >> $HOME/cron_log/cron.log 2>&1
r0_adms 26540 26367 1 14:17:00 ? 0:00 sh -c (. $HOME/set_dmsenv.sh; tb_monitor.sh) >> $HOME/cron_log/cron.log 2>&1
r0_adms 26542 26540 0 14:17:00 ? 0:00 sh -c (. $HOME/set_dmsenv.sh; tb_monitor.sh) >> $HOME/cron_log/cron.log 2>&1
r0_adms 26367 26363 1 14:17:00 ? 0:00 sh -c (. $HOME/set_dmsenv.sh; tb_monitor.sh) >> $HOME/cron_log/cron.log 2>&1
In this case set_dmsenv.sh simply adds the necessary paths and variables for our DMS environment.
We are running HPUX B.11.23 U ia64.
Has anyone experienced this? If so is this expected behavior and does anyone know how to prevent it?
Thanks in advance
- Tags:
- cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-09-2010 06:25 AM
тАО11-09-2010 06:25 AM
Re: Cron spawning multiple processes
I wouldn't think so!
How many 'cron' processes do you have?
What does 'UNIX95= ps -C cron' show? (Note the space between the = and the 'ps')
If there is more than 1 then that may be your problem.
You could try stopping a restarting cron.
# /sbin/init.d cron stop
Make sure there are no 'cron' processes running.
# /sbin/init.d/cron start
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-09-2010 06:40 AM
тАО11-09-2010 06:40 AM
Re: Cron spawning multiple processes
Thank you for your response. I tried this but only see one cron process:
UNIX95= ps -C cron
PID TTY TIME CMD
2716 ? 01:34 cron
Kind regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-09-2010 07:07 AM
тАО11-09-2010 07:07 AM
Re: Cron spawning multiple processes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-09-2010 12:34 PM
тАО11-09-2010 12:34 PM
Re: Cron spawning multiple processes
Not by cron(1m). These are all done by the shell. You need to get a hierarchical dump of the process tree:
UNIX95=EXTENDED_PS ps -H -fu r0_adms
r0_adms 26363 2176 sh -c (. $HOME/set_dmsenv.sh; tb_monitor.sh)
r0_adms 26367 26363 sh -c (. $HOME/set_dmsenv.sh; tb_monitor.sh)
r0_adms 26540 26367 sh -c (. $HOME/set_dmsenv.sh; tb_monitor.sh)
r0_adms 26542 26540 sh -c (. $HOME/set_dmsenv.sh; tb_monitor.sh)
It looks like the shell is forking itself.
>In this case set_dmsenv.sh simply adds the necessary paths and variables
I assume this completes and you do get to tb_monitor.sh?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-10-2010 12:35 AM
тАО11-10-2010 12:35 AM
Re: Cron spawning multiple processes
I created a small file which simply writes the current unix time to a file and called that, here is the output from it. What I don├В┬┤t understand here is the awk line. There is no awk scripting in the set_dmsenv.sh file at all, nor in my example script. As I say, this file does nothing apart from setup environment variables.
r0_pdms 19792 2716 0 09:10:00 ? 00:00 sh -c (. $HOME/set_dmsenv.sh; ~/rh/test.sh)
r0_pdms 19794 19792 2 09:10:00 ? 00:00 sh -c (. $HOME/set_dmsenv.sh; ~/rh/test.sh)
r0_pdms 19953 19794 0 09:10:00 ? 00:00 /usr/bin/awk {for (i=1; i<= NF; ++i) if( $i != VAR ) print $i":"} FS=: VAR=/opt/IBM/db2ia32/sqllib/java/db2jcc.jar
r0_pdms 19954 19953 0 09:10:00 ? 00:00 sh -c (. $HOME/set_dmsenv.sh; ~/rh/test.sh)
r0_pdms 19955 19954 0 09:10:00 ? 00:00 /usr/bin/echo /opt/IBM/db2ia32/sqllib/java/db2java.zip
Here is my test script:
#!/bin/ksh
epoch=`date "+%s"`
echo $epoch>>test.out
Although this script appears to spawn 3 times using my previous method I do only get one line of output in the test.out file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-10-2010 01:32 AM
тАО11-10-2010 01:32 AM
Re: Cron spawning multiple processes
r0_pdms 23173 2716 1 10:05:00 ? 00:00 sh -c (. $HOME/set_dmsenv.sh; mdmsadminclient r) >>$HOME/cron_log/cron.log 2>&1
r0_pdms 23180 23173 2 10:05:00 ? 00:00 sh -c (. $HOME/set_dmsenv.sh; mdmsadminclient r) >>$HOME/cron_log/cron.log 2>&1
r0_pdms 23364 23180 0 10:05:00 ? 00:00 /usr/bin/sed s/\: /\:/g
r0_pdms 23368 23364 0 10:05:00 ? 00:00 sh -c (. $HOME/set_dmsenv.sh; mdmsadminclient r) >>$HOME/cron_log/cron.log 2>&1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-10-2010 01:42 AM
тАО11-10-2010 01:42 AM
Re: Cron spawning multiple processes
Do you export ENV to set up a .kshrc file?
What's in set_dmsenv.sh?
You may want to add "set -x" to your script AND to set_dmsenv.sh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-10-2010 02:57 AM
тАО11-10-2010 02:57 AM
Re: Cron spawning multiple processes
I took out the scripts altogether and just call the set_dmsenvtest.sh script:
UID PID PPID C STIME TTY TIME CMD
r0_pdms 20840 2716 1 11:43:00 ? 00:00 sh -c (. $HOME/set_dmsenvtest.sh)
r0_pdms 20857 20840 2 11:43:01 ? 00:00 sh -c (. $HOME/set_dmsenvtest.sh)
r0_pdms 21041 20857 0 11:43:01 ? 00:00 /usr/bin/awk {for (i=1; i<= NF; ++i) if( $i != VAR ) print $i":"} FS=: VAR=.
r0_pdms 21043 21041 0 11:43:01 ? 00:00 sh -c (. $HOME/set_dmsenvtest.sh)
r0_pdms 21045 21043 0 11:43:01 ? 00:00 /usr/bin/echo /opt/IBM/db2ia32/sqllib/java/db2java.zip:/opt/IBM/db2ia32/sqllib/java/db2jcc.jar:/opt/IBM/db2ia32/sqllib/java/db2
I have attached the set_dmsenvtest.sh file. In the .environ file we have the following:
set -o trackall
alias history='fc -l -20'
alias h='fc -l -20'
alias dir='ls -la |more -cs '
alias -t
alias um='set -- -1;. um'
alias psu='ps -fu $LOGNAME|grep -v "ps -fu"'
alias lb='cd ${MBASE}/locbin;x'
alias sm='cd ${MBASE}/seriem;x'
alias mb='cd ${MBASE};x'
Thanks for your help so far.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-11-2010 02:41 AM
тАО11-11-2010 02:41 AM
Re: Cron spawning multiple processes
It seems it is bad.
>In the .environ file we have the following:
That seems safe.
What's in ${DB2HOME}/sqllib/db2profile?
>HostName=*********
This isn't going to work, change to:
HostName="*********"
(Unless the censor got to it. :-)
You have "set +x" at the top. You need "set -x" to trace.