Crontab spawning multiple at processes


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Crontab spawning multiple at processes
# 1  
Old 08-17-2008
Crontab spawning multiple at processes

Hi - I need help. My user crontab is spawning multiple at processes (and multiple mencoder program starts, that exit, then restart, repeatedly), locking up my system.

For example I have this entry in my crontab:

$ sudo crontab -u victoria -e

* * * * * ~/recordings/pvr1
* * * * * ~/recordings/pvr2
[etc.]

where pvr1, pvr2, etc. are executable bash script files, e.g. pvr1 is:

Code:
#!/bin/sh
at -f ~/recordings/record_tv_1 12:58 pm Aug 17 2008
exit

As you can see, this calls my mencoder ecording file, record_tv_1:

tuner=/dev/video1 # or, /dev/video1 for the 2nd PVR-150 tuner in my Hauppauge PVR-4500 card
channel=70
duration=01:04:00 # hh:mm:ss
record_directory=/media/sdb1/recordings/UNPROCESED/
# record_directory=/home/victoria/temp/UNPROCESED/
file_name=Dog_Genius

ivtv-tune -c $channel -d $tuner

sleep 1

mencoder pvr:// -tv \
driver=v4l2:width=640:height=480:input=0:device=$t uner:norm=NTSC:chanlist=us-cable:outfmt=yuy2:adevice=/dev/dsp:audiorate=44100 \
-vf lavcdeint \
-ovc lavc \
-lavcopts vcodec=mpeg4:vbitrate=4500:keyint=3 \
-oac mp3lame \
-lameopts br=128:cbr:mode=3 \
-ffourcc divx \
-endpos $duration \
-quiet \
-o $record_directory$file_name"_"`date +%A_%B_%d_%Y_%I:%M_%p`.avi

The problem is that virtually every time the pvr script is called by crontab, it spawns (continuously) multiple/new at command processes (Process Viewer), and also several mencoder processes that continually start, stop, relaunch, that are multiply-present in Process Viewer at any one time. The recordings are all partial files (snips). This had been working properly, until about a month ago (Ubuntu updates, screwing things up?).

I'd appreciate it is someone could explain to me what the problem is. FYI: I am using Ubuntu 8.04 LTS -Hardy Heron.

Thanks, appreciated, Greg :-)

Last edited by Yogesh Sawant; 06-23-2009 at 03:55 AM.. Reason: added code tags
# 2  
Old 08-17-2008
If you are calling these scripts from cron every minute, then it is no surprise that multiple at jobs are being scheduled... why do you need the crontab entries at all? Why don't you just schedule the programs directly through at?
# 3  
Old 08-17-2008
ya if you are using crontab to shedule why are you again using at command in your script??
# 4  
Old 08-18-2008
Hi - Thank you for your replies ... I had intended to schedule the recordings from a script, avoiding the more tedious route via crontab itself. Regardless, since the bash scripts contain a single at command (scheduled time), I don't why cron is repeatedly spawning multiple processes (at commands, for the single, scheduled event).

That is, despite reading the file every minute, once this scheduled at command has been executed (at the appropriate time), shouldn't further calls to this bash file (with a now-expired at command start time) simply be ignored?

Or, it it the case that since the crontab-called file hasn't run it's course (completed, e.g for a scheduled recording of 1 hour), that cron thinks that the command hasn't executed, and tries to execute at the next available opportunity (here, every 1 minute)?

FYI, after I posted my original question, I had the idea (subsequently suggested, above), and directly called my record_tv_* scripts from crontab, which seems to be the solution - not quite what I had wanted, but so be it.

E.g.,

58 18 17 aug sun ~/recordings/record_tv_1
# 5  
Old 08-18-2008
I agree that it sounds like something is going wrong there, and I'm not sure what's causing it. But what I don't understand is why you are using crontab at all. When you want to schedule a recording, just run the at command once, as you had in the bash script... job done? It will only run once, at the scheduled time, and then it will be forgotten about.
# 6  
Old 08-18-2008
When you set up your cron, you set it to call the script every minute. So, every minute, cron calls your script and your script schedules an at job. When that time arrives, the system will start running all of those queued up jobs scheduled by at.

Once you have passed the time specified in the at command, cron is still going to call your script (every minute) and it is going to try to schedule the at. Since the time is now passed, those at jobs should not be scheduled, but cron and the script are going to continue to run. How do you expect them to know that the time is expired? At will know the time is already expired and refuse to schedule a new job but everything leading up to that point is still going to happen.
# 7  
Old 08-18-2008
Yes, I understand (fully) now ... thanks. Cron was the wrong approach - stick with "at," as suggested.

A related question: How can I delete those (100's, if not 1000's) of scheduled processes (at commands), a legacy from cron?

I know that I can remove specific job ids using atrm, but it won't accept wildcards. There are simply too many of these, to remove tyhem via atrm, one at a time.

Thanks again - Greg :-)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Script on Solaris spawning 2 processes for one shell script execution

Hi, I am having a shell script on Solaris 10 which has a while loop as shown below. #!/usr/bin/ksh # while do sleep 60 done Name of the shell script is coldcentric.sh. I executed script /DATAWAREHOUSE/LOAD/Scripts/coldcentric.sh from a command task in Informatica worklow as... (3 Replies)
Discussion started by: chekusi
3 Replies

2. Shell Programming and Scripting

Shell script executed from Informatica ETL tool is spawning 2 processes for one script

Hi, I am having a shell script which has a while loop as shown below. while do sleep 60 done I am executing this script from Informatica ETL tool command task from where we can execute UNIX commands/scripts. When i do that, i am seeing 2 processes getting started for one script... (2 Replies)
Discussion started by: chekusi
2 Replies

3. AIX

Multiple pconsole processes spawning indefinetly

Good night everyone, I've been trying to make AD authentication work with RBAC and I think I messed my test LPAR up. I've manually modified the /etc/security/user.roles file, adding a role to one of my AD users (who is not defined locally) and then runned setkst. It worked fine, but now I found... (3 Replies)
Discussion started by: Janpol
3 Replies

4. Shell Programming and Scripting

need help ps -e on multiple processes

:)Hi there, I am new to scripting and wanted to see if someone can show me how to grep on multiple processes and send the output to a file in /home/mydir/output. I am aware of ps -ef | grep on 1 process but need help looking up multiple processes, can you use this command ps -elf | grep |pid1... (4 Replies)
Discussion started by: abbya
4 Replies

5. Shell Programming and Scripting

kill multiple processes by name

Want to kill multiple processes by name. for the example below, I want to kill all 'proxy-stagerd_copy' processes. I tried this but didn't work: >> ps -ef|grep proxy_copy root 991 986 0 14:45:34 ? 0:04 proxy-stagerd root 1003 991 0 14:45:49 ? 0:01... (2 Replies)
Discussion started by: catalinawinemxr
2 Replies

6. UNIX for Dummies Questions & Answers

If user has own crontab, results in accumulation of root CRON processes

Hello, I seem to be having a problem with accumulation of root CRON jobs occuring when I have a user's cron job(s) running. Here is an example of a user's crontab file: */1 * * * * echo "hello" > /dev/nullps aux|grep CRON root 14333 0.0 0.0 91236 2172 ? S ... (12 Replies)
Discussion started by: Narnie
12 Replies

7. UNIX for Advanced & Expert Users

Help! imapd is spawning multiple processes, all of a sudden, for no reason!

Hi All, I need some assistance, if possible... Our IMAP server has recently (as of 10:30 GMT today) started spawning multiple processes for no reason! This is causing the mail server's load average to increase continually until the whole machine grinds to a halt. Here is a typical... (0 Replies)
Discussion started by: fishsponge
0 Replies

8. Shell Programming and Scripting

Spawning multiple threads in Unix

Hi, I need to spawn mutilpe threads , each invoking a different set of shell scripts, in parallel. What would be the best way to do that. Any sample script would greatly help. I am a novice at Unix so any help is much appreciated. Thanks (5 Replies)
Discussion started by: neeto
5 Replies

9. Shell Programming and Scripting

Doubt about multiple processes

Suppose that I am performing some operation on an sql database. Lets say process of Searching and then if a value is found, updating it... Now, when I have some millions of records on which the operation has to be performed... Does it help to spawn multiple processes each executing the same... (9 Replies)
Discussion started by: Legend986
9 Replies

10. Programming

spawning multiple processes spread across two files

I want to spawn n child processes but have two different classes..with the foremost one forking/spawning the child process and the latter performing a function w/ the spawned processes. I can do this in one class with an if statement and the simple if((pid=fork())==0) //child process { ... (1 Reply)
Discussion started by: StrengthThaDon
1 Replies
Login or Register to Ask a Question