LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-30-2009, 03:58 AM   #1
WojtekO
Member
 
Registered: May 2006
Distribution: CentOS 5
Posts: 47

Rep: Reputation: 15
crond and sh looping if nfs fails on remote server


Hello there,

I've ran into the following problem:

I currently have a cron setup that runs every minute. It's basically something like:
Code:
* * * * * /script.sh > /mnt/otherserver
Problem is, if NFS fails on otherserver, I get an endless ammount of crond and sh populating the process list which eventually causes the load to increase as high as 80-100 which then causes other problems.

I've tried to fix the problem my mounting like this:
Code:
 (rw,proto=tcp,timeo=20,retrans=6,hard,intr,rsize=16192,wsize=16192,addr=192.168.10.216)
I believed the 20 second timeout would solve the problem but it did not.

Anyone could suggest something else to avoid this problem?

Thank You
 
Old 04-30-2009, 03:45 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
You should modify script.sh so that it detects whether a copy is already running and exits if so. Something like this:

#!/bin/bash

if ps -ef |grep script.sh |grep -v grep
then echo ERROR: script.sh already running.
exit 2
fi

...rest of the script...

That way it will abort regardless of the reason it is still running including NFS failure.
 
Old 04-30-2009, 10:10 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,420

Rep: Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785
IMHO, even though cron can go down to 1 minute intervals, anything more than every 5 mins & I seriously consider writing a daemon instead.
all you need is

nohup infinite_loop_around_code &

Creating a new process every minute is adding to the system load unnecessarily. This also automatically avoids more than one copy running.
I'd also change the nfs params to use soft instead of hard.
You can easily get the daemon to check the mnt before trying to use it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Debian Fails to Remount NFS Share on Server Reboot userlander Debian 3 02-13-2009 01:56 PM
NFS V4 mount fails - Server side says idmapping failing sixerjman Linux - Software 0 07-24-2007 11:05 PM
nfs install fails manual mounting remote share dohpaz Slackware - Installation 3 05-04-2007 01:00 PM
cron spawning extra crond - script fails jbob75 Linux - Software 2 11-21-2005 05:29 AM
rhel4 2.6.9-5.0.5.ELsmp nfs mount fails, server is down timvand Linux - Enterprise 1 04-24-2005 08:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration