Operating System - HP-UX
1748102 Members
5427 Online
108758 Solutions
New Discussion

Re: Cron job (proces handling)

 
Milos_Lucic
Advisor

Cron job (proces handling)

Hi to all,

 

I'm curious to find out why cronjobs which runs every hour for example i have script which runs every hour leaves process in sleep state when finishes and again on same call leave new process in sleep state with new PID so i have multiple prcocesses on system in sleep state.  System is HP-UX 11.23 i guess that process from cron should override previous jobs.

9 REPLIES 9
Patrick Wallek
Honored Contributor

Re: Cron job (proces handling)

Cron itself will NOT terminate any scripts that were previously started via cron.  

 

Basically, if you have a script that runs via cron and one instance of the script does not finish before cron runs it the next time, you WILL wind up with multiple copies of the script running.

 

 

Dennis Handly
Acclaimed Contributor

Re: Cron job (proces handling)

>I guess that process from cron should override previous jobs.

 

Only if you add code to kill any PIDs from previous runs.

Do you know why it is sleeping?

pooderbill
Valued Contributor

Re: Cron job (proces handling)

cron does only one thing: start processes

nothing else.

There is no code in cron to monitor what is started or to prevent overlapping processes.

This is a common problem when trying to schedule sequential backups. There is no guarentee that a backup will always take the same length of time to run.

 

Run the process or script by hand and troubleshoot the result.

Milos_Lucic
Advisor

Re: Cron job (proces handling)

First thank for answers,

 

Well that's why i'm wondering why they are in sleep state so i see many sleeping process which are from sh or ksh.

For example cronjob

 

/usr/sbin/sh or ksh then some shell.script which collects certain data

 

When i check process from script it have parrent process with child process which are encountering again and again with new pid.

 

Problem here is because on system it is defined that max process per user is 1024 and crontabs of that user came to that limit and exceed it and now from 1029 process i have many that are in sleep state. They don't consume CPU but on every hour when crontab job is on run load are on highly level.


What here concerns me is that average load is on 8  8  8 and from restart of  Server it was 0.17  0.19  0.19 which is big difference.

I try to kill some of process by hand but on every crontab, load go up and amount of process rise up.

pooderbill
Valued Contributor

Re: Cron job (proces handling)

The script needs to be debugged. Use the -x option to manually trace the script, and check the user's (root) email for error messages. If the script runs OK when run from a login shell, it is likely the script writer did not know that cron does not provide the same environment as a login.

Dennis Handly
Acclaimed Contributor

Re: Cron job (proces handling)

>I'm wondering why they are in sleep state so I see many sleeping process which are from sh or ksh.

 

You could try using tusc to see what they are doing.

 

tusc -fp -ea -o tusc.out -p <pid>

Milos_Lucic
Advisor

Re: Cron job (proces handling)

Well for sure i will have to check some scripts because they dont run fine as they should. But that doesn't deal with process because process do what they need to to do by cron job and they write output in mail of user which cron job is not running if there is some problem. Process that run hourly made problems so i need to stop many of them by kill and also to stop cron job. Anyway i will have to run that cronjobs again because they have to be running on system. What here concerns me that process from crontab with every execution runs and load CPU while other go in sleep time and occupies CPU time (in sleep state) also which have impact on performance. So it would be tiresome to kill all sleeping proces all the way. That's why i post this thread to see if i could do something to cut of sleeping process of having impact on system.

 

I didn't use tusc command and seems that it doesn't exist in list of hp-ux commands or man pages.

Dennis Handly
Acclaimed Contributor

Re: Cron job (proces handling)

> occupies CPU time (in sleep state)

 

If sleeping, it shouldn't use CPU time, unless continually waking.

 

>I didn't use tusc command and seems that it doesn't exist in list of HP-UX

 

You can download it here:

http://hpux.connect.org.uk/hppd/hpux/Sysadmin/tusc-8.1/

Milos_Lucic
Advisor

Re: Cron job (proces handling)

Well yes it occupies CPU while they sleepng (after some time they wake up) because they are mmlmacro commands i will take deep investigation about these process. It's nice to see  some free tool. Thanks for sharing. I mainly lean on sar, top  and vmstat for monitoring system. Glance is very good also but its not free.