Subscribe to Posts by Email

Subscriber Count

    696

Disclaimer

All information is offered in good faith and in the hope that it may be of use for educational purpose and for Database community purpose, but is not guaranteed to be correct, up to date or suitable for any particular purpose. db.geeksinsight.com accepts no liability in respect of this information or its use. This site is independent of and does not represent Oracle Corporation in any way. Oracle does not officially sponsor, approve, or endorse this site or its content and if notify any such I am happy to remove. Product and company names mentioned in this website may be the trademarks of their respective owners and published here for informational purpose only. This is my personal blog. The views expressed on these pages are mine and learnt from other blogs and bloggers and to enhance and support the DBA community and this web blog does not represent the thoughts, intentions, plans or strategies of my current employer nor the Oracle and its affiliates or any other companies. And this website does not offer or take profit for providing these content and this is purely non-profit and for educational purpose only. If you see any issues with Content and copy write issues, I am happy to remove if you notify me. Contact Geek DBA Team, via geeksinsights@gmail.com

Pages

prstat –z disaster in crontab (realtime issue) possible hit to you as well, if you are too keen on automations.

Many thanks to Shiva & Swathi for sharing their real time experience and appreciating their wish to share this to in my blog.

Further, the following is very nice work from Swathi with screenshots and well written to understand the situation and how to resolve the same!!!

Read on!!!

Sharing one situation of my learning experience.

Please be careful while using below commands in cronjobs.

prstat -Z
top

Please use top -d 2 to capture output of top command. This will run top command twice with an interval of 5 seconds(default).

For the first run top won't give any valid output...only 0's will be displayed.
For Example:

top

And when using prstat -Z in cronjob , You  might have used in below format.

prstat -Z 5 1

( 5 -means interval of 5 seconds(default) 1-means one iteration) This makes prstat command to run once and exit...else it will be running continuously till we manually kill it.

Disasters that can happen:

  • First run of the cronjob will trigger prstat -Z and will run continuously ...so our script won't exit.
  • As per our cron schedule, cronjob will be triggered again ....so prstat -Z will run again with new process id and as a consequence our script won't exit again.
  • Here we will be having 2 instances of same job running. In case we schedule the cronjob every 5 minutes, within one hour 12 instances of our script and 12 instances of prstat -Z will be running....resulting in an increase of CPU & memory usage.
  • If this continues ......

Our cron jobs won't run..... (Surprizing !!!!)  Why?

5. There is one location where we can check what happened to cron....

$ cd /var/cron

pic1 

6. Why does a cronjob get rescheduled???

But the script runs successfully when run manually...what could the reason be?? Insufficient RAM ???
nono

The reason is,

By default a cron can run only 100 jobs at a time from its queue. (new learning to me :()

Let check, how many jobs a cron is running currently ?

pic2 

Here 277 is process id of cron.

pic3 
See, Cron is already holding 100 jobs which haven't exited. This is the reason for rescheduling/halting of all cronjobs.

All this happened because of prstat –Z

pic4 
A whole day !!!!!!!! crying watching, the jobs to back normal

After killing all these prstat processes.....everything came back to normal...

All cronjobs are running on time....  Hooooooray!!!!!

Morale:- To those who fond of automations, these are disastrous sometimes where you have no control.

-Thanks

Geek DBA.(On behalf of Swathi & Shiva)

2 comments to prstat –z disaster in crontab (realtime issue) possible hit to you as well, if you are too keen on automations.

  • Seshu

    Hi Geek DBA,

    Wow grate contribution from Swathi & Shiva, and i would like to say thank you to all of you for sharing this article.

    Regards,
    Seshu

  • Aravindhan Kumar

    Been using cron in a number of ways, But like you said and i quote “new learning to me :(“.

    Good read guys!