Sleep 600 or fork/spawn a process or daemon?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sleep 600 or fork/spawn a process or daemon?
# 1  
Old 05-17-2014
Sleep 600 or fork/spawn a process or daemon?

Hi,

I have a script that run every 10 minutes, from a specific timeframe of the day, for example 0500 - 1900.

The script is some sort of checker script for an application log file and check for errors and email us if there is error/s reported in the log.

At the moment, I schedule it to start as a cron at 0500, then inside the script I check for whether the hour is less than 1900 and if it is then I continue running the script. In between checks, I have a sleep 600 = 10 minutes. I want to know if this is the most efficientway of running the script.

I've found some information on fork/spawn and daemon, while they sound like 'cool' terminology Smilie I don't really know the concept on whether they apply to what I want for the script.

Does having the script to be able to run within specific timeframe qualify it to be some sort of a daemon?

Anyway, I know one of the resident gurus will be able to shed some light on my over-analyzing what I am wanting to do.

Thanks in advance.
# 2  
Old 05-19-2014
You can schedule it every 10 minutes with cron. Example crontab entry :
0,10,20,30,40,50 * * * * /path/to_my_script.sh >> /path/to/logfile

This avoids one problem with sleep. Creep. Over the period of several months due to the way the scheduler works on a busy system, sleep 600 is guaranteed to sleep AT LEAST 600 seconds, but it could be more like 600.1 seconds. The start time of the script eases forward every day. Could end up starting several seconds late.

cron does not have this problem.

If this is a non-issue for you go with your sleep solution. That way you can check if it is running with
Code:
ps -ef | grep [script filename goes here]

Otherwise you would have to look at a log file or employ some other less convenient method than ps.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Process remians in Running state causing other similar process to sleep and results to system hang

Hi Experts, I am facing one problem here which is one process always stuck in running state which causes the other similar process to sleep state . This causes my system in hanged state. On doing cat /proc/<pid>wchan showing the "__init_begin" in the output. Can you please help me here... (6 Replies)
Discussion started by: naveeng
6 Replies

2. UNIX for Advanced & Expert Users

Process remians in Running state causing other similar process to sleep and results to system hang

Hi Experts, I am facing one problem here which is one process always stuck in running state which causes the other similar process to sleep state . This causes my system in hanged state. On doing cat /proc/<pid>wchan showing the "__init_begin" in the output. Can you please help me here... (1 Reply)
Discussion started by: naveeng
1 Replies

3. BSD

Process remians in Running state causing other similar process to sleep and results to system hang

Hi Experts, I am facing one problem here which is one process always stuck in running state which causes the other similar process to sleep state . This causes my system in hanged state. On doing cat /proc/<pid>wchan showing the "__init_begin" in the output. Can you please help me here... (0 Replies)
Discussion started by: naveeng
0 Replies

4. Shell Programming and Scripting

Spawn and join multiple process

I am doing some file manipulation and then a bcp once all the files are processed. I need to do the following for all files in dirctory begin -Step 1 use another shell/perl to format the file done in the end load into db using bcp I want to do step 1 and step in a seperate... (2 Replies)
Discussion started by: tasmac
2 Replies

5. Shell Programming and Scripting

Using expect command, spawn will not start sftp process

Hi all, I have a script that runs sftp with expect so I can login and send a file in a cronjob. I've installed this on a couple other servers and it has been fine. However, this time on this machine, it seems to be giving me an issue. It won't move past the spawn sftp command and return a... (3 Replies)
Discussion started by: ltyrrell
3 Replies

6. UNIX for Advanced & Expert Users

spawn() Vs. fork()

what is diffenrence between spawn and fork ? "fork() system call spawns the processess" what is mean by this sentence. (1 Reply)
Discussion started by: anandgodse
1 Replies

7. Programming

spawn a process with a different user

Hello Everyone: I have the following code int main() { system("/usr/OtherUser/bin/runX"); return 0; } runX must be executed with privileges from another user, how could I do that? I know the password for such user. Thanks in advance (8 Replies)
Discussion started by: edgarvm
8 Replies

8. UNIX for Dummies Questions & Answers

How can i use fork,sleep,wait and write in a process with father and son..??

Hi.. I was unable to do (gcc code) which refers to the fork,wait,sleep and write.. what i want to do: A process of father create (fork) a son and will sleep 90 seconds..After this, son process create a grandchild and will sleep 60 seconds..Grandchild process will sleep for 30 seconds..After... (3 Replies)
Discussion started by: gumlucin
3 Replies

9. Shell Programming and Scripting

how to start a process and make it sleep for 5 mins and then kill that process

how to start a process and make it sleep for 5 mins and then kill that process (6 Replies)
Discussion started by: shrao
6 Replies

10. UNIX for Advanced & Expert Users

my process is going to sleep mode after 12 hours but i need my process in in firsy pr

hi all I process is sleeping after 12 hours but i need to be run this to 24 hours but it goes in sleep mode after 12 hours what should i do to make process always running.Kindly give me suggestion. (0 Replies)
Discussion started by: mukesh_rakesh1
0 Replies
Login or Register to Ask a Question