The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Accessing variables of one shell script in another shell script rsendhilmani Shell Programming and Scripting 2 03-17-2009 01:17 AM
To call/execute a shell script from a shell script konark UNIX for Dummies Questions & Answers 1 10-26-2007 05:16 PM
How to pass a parameter from one Shell-script to another Shell-script subodhbansal Shell Programming and Scripting 2 09-22-2007 05:19 AM
Have a shell script call another shell script and exit heprox Shell Programming and Scripting 2 11-20-2006 08:17 AM
shell script as a daemon massoo Shell Programming and Scripting 1 05-15-2006 12:04 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-16-2007
Sammy_T Sammy_T is offline
Registered User
  
 

Join Date: May 2007
Posts: 4
Run shell script as a daemon

I have simple shell script that I run as cron job every hour of the day. I would like to make it a daemon that runs far more frequently like every 30 seconds or so, but I have never made daemon before. How can I do this?

-Sam
  #2 (permalink)  
Old 05-16-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Sam,
Use "cron".
In unix, do a man page to it:
man cron
  #3 (permalink)  
Old 05-16-2007
Sammy_T Sammy_T is offline
Registered User
  
 

Join Date: May 2007
Posts: 4
Sure,

I would like to keep using cron, but will I be able to run a cron job say every minute at least. I was always under the impression that running a cron job in intervals under 5 minutes was not the best practice. Please advise because I could really be wrong.
  #4 (permalink)  
Old 05-16-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by Sammy_T
Sure,

I would like to keep using cron, but will I be able to run a cron job say every minute at least. I was always under the impression that running a cron job in intervals under 5 minutes was not the best practice. Please advise because I could really be wrong.
Having any program wake up after only a few seconds and do something is bad-practice. It is far better for a program to wake up as a result of a specific event (signal, file descriptor read, semaphore etc).

If you really must then kick it down in priority with nice.
  #5 (permalink)  
Old 05-17-2007
Sammy_T Sammy_T is offline
Registered User
  
 

Join Date: May 2007
Posts: 4
The program would be awakening a checking for "list of worK". If it meets the programs criteria, it will run a method against it and move it to the next level of processing which it is not responsible for. So having it run more frequently ensures that the user does not have to wait at least 5 minutes, because the program executes quicly when it does run.
  #6 (permalink)  
Old 05-16-2007
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,847
Or use something like this:

Code:
while :;do
	# your code here
	sleep 30
done
  #7 (permalink)  
Old 05-16-2007
Sammy_T Sammy_T is offline
Registered User
  
 

Join Date: May 2007
Posts: 4
Should I insert that example code into my java program or add it to my shell script which runs the java program?
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:27 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0