Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

bash script with time delay [solved]

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
4 posts • Page 1 of 1
Author
Message
Specialized
Apprentice
Apprentice
User avatar
Posts: 264
Joined: Tue Jan 11, 2005 5:31 pm

bash script with time delay [solved]

  • Quote

Post by Specialized » Fri Oct 28, 2005 6:24 pm

Hi,
I want to write a little bash script which checks if an internet Connection is established and then starts the ntp-client.
If there is no connection it should wait about 25 s and try again.
At the Moment it looks like this:

Code: Select all

 if ping -c1 www.google.de | grep "1 received"; 
	then /etc/init.d/ntp-client start; 
else /home/hannes/Connections/./ntp.sh;
fi
But this costs a lot of Systemresources til the Client has started.
I'm looking for something like that:

Code: Select all

if ping -c1 www.google.de | grep "1 received"; 
	then /etc/init.d/ntp-client start; 
else "wait for 25 seconds and execute /home/hannes/Connections/./ntp.sh again";
fi
Any ideas how to do this?
Last edited by Specialized on Fri Oct 28, 2005 6:51 pm, edited 1 time in total.
Top
garion911
Tux's lil' helper
Tux's lil' helper
Posts: 88
Joined: Tue Jun 04, 2002 1:30 pm

  • Quote

Post by garion911 » Fri Oct 28, 2005 6:29 pm

try:

Code: Select all

if ping -c1 www.google.de | grep "1 received";
   then /etc/init.d/ntp-client start;
else sleep 25 && /home/hannes/Connections/./ntp.sh;
fi
Top
mens
Guru
Guru
User avatar
Posts: 392
Joined: Wed Aug 27, 2003 2:53 pm
Location: Belgium

  • Quote

Post by mens » Fri Oct 28, 2005 6:33 pm

do sth like

Code: Select all

ping -c1 www.google.de
while [ $? -ne 0 ]
do
    sleep 25
    ping -c1 www.google.de
done
/etc/init.d/ntp-client start
Top
Specialized
Apprentice
Apprentice
User avatar
Posts: 264
Joined: Tue Jan 11, 2005 5:31 pm

  • Quote

Post by Specialized » Fri Oct 28, 2005 6:50 pm

That's it, thank's!!!!
Top
Post Reply

4 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic