LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 07-04-2015, 11:10 AM   #1
asarangan
Member
 
Registered: Jul 2009
Posts: 89

Rep: Reputation: 18
Strange cron behavior


I have an audio recording script file that runs for slightly over an hour. I want it to start the job on the top of each hour. There will be a brief moment when two jobs will overlap, but that should not be a problem - I can run two of the same script on the console without any errors. However, the problem is, the cron is invoking the job only once every 2 hours, not every hour. The jobs that are invoked, run to completion without any errors. I am piping stdout and stderr to file, and there are no error messages. This is on Slackware 14.1 64-bit. Crond is obviously running - '/usr/sbin/crond -l notice'.


/home/myuserid/myscript:

#!/bin/bash

STP=$(date +%s)
arecord -D plug:dsnoop -d 3600 -r 11025 -f S16_LE sounds/$STP.wav
sox -q sounds/$STP.wav sounds/$STP-1.wav silence -l 1 0.1 0.1% -1 1 0.1%
lame --quiet sounds/$STP-1.wav $STP.mp3

---------------------
crontab entry:
0 * * * * /home/myuserid/myscript >> /tmp/myscript_err 2>&1
 
Old 07-04-2015, 12:00 PM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
I think the reason is that the script takes more than one our to run. Cron will not start the script when it's already running. Maybe add & at the end?
 
Old 07-04-2015, 08:04 PM   #3
asarangan
Member
 
Registered: Jul 2009
Posts: 89

Original Poster
Rep: Reputation: 18
Quote:
Originally Posted by Guttorm View Post
I think the reason is that the script takes more than one our to run. Cron will not start the script when it's already running. Maybe add & at the end?
Here is a little more info. I ran the following script (mydate_sleep.sh) every minute
#!/bin/bash
date
sleep 65

Crontab entry is this:
* * * * * mydate_sleep.sh >> /tmp/mydate_sleep

The output file /tmp/mydate_sleep looks like this:
Sat Jul 4 20:10:01 EDT 2015
Sat Jul 4 20:12:01 EDT 2015
Sat Jul 4 20:13:01 EDT 2015
Sat Jul 4 20:15:01 EDT 2015
Sat Jul 4 20:17:01 EDT 2015
Sat Jul 4 20:19:01 EDT 2015
Sat Jul 4 20:21:01 EDT 2015
Sat Jul 4 20:23:01 EDT 2015
Sat Jul 4 20:25:01 EDT 2015
Sat Jul 4 20:27:01 EDT 2015
Sat Jul 4 20:29:01 EDT 2015
Sat Jul 4 20:31:01 EDT 2015
Sat Jul 4 20:33:01 EDT 2015
Sat Jul 4 20:35:01 EDT 2015
Sat Jul 4 20:37:01 EDT 2015
Sat Jul 4 20:39:01 EDT 2015
Sat Jul 4 20:41:01 EDT 2015
Sat Jul 4 20:42:01 EDT 2015
Sat Jul 4 20:44:01 EDT 2015
Sat Jul 4 20:46:01 EDT 2015
Sat Jul 4 20:48:01 EDT 2015
Sat Jul 4 20:50:01 EDT 2015
Sat Jul 4 20:52:01 EDT 2015
Sat Jul 4 20:54:01 EDT 2015
Sat Jul 4 20:56:01 EDT 2015
Sat Jul 4 20:58:01 EDT 2015


Notice that the script run every two minutes (instead of one minute), but not always. Sometimes it runs every minute. Check the 3rd and 18th outputs. Those are one minute apart. I am confused by this unpredictable behavior. If I remove the "sleep 65" from the script, then it runs every minute.

This is on dillon's cron daemon 4.5.

Last edited by asarangan; 07-04-2015 at 11:21 PM.
 
  


Reply



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
funky cron.d odd behavior DirtyHowi Linux - General 1 09-01-2014 11:10 PM
cron behavior issue with ls -l kb2001 Linux - General 4 02-03-2012 12:11 AM
Strange Cron directories: /var/spool/cron/cron.GfqqGO Woodsman Slackware 4 05-11-2011 02:37 PM
Odd cron behavior with CentOS5 jakev383 Linux - General 4 04-30-2008 10:34 AM
Can't *really* understand cron behavior maxbld Linux - General 3 11-21-2002 09:26 AM

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

All times are GMT -5. The time now is 04:23 AM.

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