scripting running every minute


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting scripting running every minute
# 1  
Old 12-30-2008
scripting running every minute

Hi Experts,

below similar thread i posted earlier. Although i wish to know ur suggestion newly.

I want to run a script every 1 minute. I tried with Crontab. But the problem is cron send every 1 mins invertal- mail to the user mailbox.

meanwhile, some expert telling me it is not wise to run short interval in crontab.

What could be best way to run this type of short interval without getting any problem in systm.

//purple
# 2  
Old 12-30-2008
If you want crontab to run without sending email, make the command not generate any output. Many commands have a -q or --quiet switch to make them not generate output. Otherwise you can redirect the output to a file or /dev/null.
Code:
some_command arg1 arg2 >/dev/null 2>/dev/null

But instead of using cron, if you are willing to accept sloppy timing, you can just keep one script running constantly and put it to sleep for a minute.
Code:
#!/bin/bash
while true; do
    some_command arg1 arg2
    sleep 60
done

This assumes you have it running in a dedicated shell and you stay logged in. But if you want to log out and let run, you can use screen (install the screen package if you don't have it--it's quite valuable).
# 3  
Old 12-30-2008
Quote:
Originally Posted by KenJackson
But instead of using cron, if you are willing to accept sloppy timing, you can just keep one script running constantly and put it to sleep for a minute.
Code:
#!/bin/bash
while true; do
    some_command arg1 arg2
    sleep 60
done


There's no need for sloppy timing:

Code:
while :
do
    sleep 60 & pid=$!
    some_command arg1 arg2
    wait $pid
done

Quote:
This assumes you have it running in a dedicated shell and you stay logged in. But if you want to log out and let run, you can use screen (install the screen package if you don't have it--it's quite valuable).

There's no need for screen. Use nohup and put it in the background.
# 4  
Old 12-30-2008
cfajohnson ,
what's a 'sloppy timing' in the previous solution?
# 5  
Old 12-30-2008
Quote:
Originally Posted by vgersh99
cfajohnson ,
what's a 'sloppy timing' in the previous solution?

It executes the command every 60 seconds plus the time it takes to execute the command.
# 6  
Old 12-30-2008
Quote:
Originally Posted by cfajohnson

It executes the command every 60 seconds plus the time it takes to execute the command.
sorry, I must be thick-sculled - I'm having hard time parsing this sentence.
Chris, could you elaborate a little bit more and why your other suggestion is any better.
In 2 words or less.....
# 7  
Old 12-30-2008
The command is initiated 60 seconds AFTER it last ran. If it requires 12 seconds to run, it will, in essence, run every 72 seconds.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Minute(4) issue in teradata

I have values below for which diff field is giving error like "invalid time interval" in teradata Might be it is not doing calculation anymore after exceeding minute(4) value END_TS 2/2/2018 08:50:49.000000 START_TS 1/5/2018 17:30:02.000000 SLA_TIME 23:59:59.000000 select... (0 Replies)
Discussion started by: himanshupant
0 Replies

2. UNIX for Beginners Questions & Answers

How to display only the first 5 running process using top in shell scripting?

topfunc() { top } topfunc Here i used the top command inside a function,and i called the function. when executing this bash file i get all the process which are using by the kernel i just want to display only the first 5 running process. is it possible? (7 Replies)
Discussion started by: Meeran Rizvi
7 Replies

3. UNIX for Dummies Questions & Answers

Need record count on every 30 minute

We have the below records where we need record count of every 30 minute like 00:01 to 00:30 so in that we will have 48 record count in 24 hrs , and also we need sum of record count from 00:01 to 23:30. Please find sample data as well. 00:01 21 00:02 23 00:03 34 00:04 34 00:05 30... (10 Replies)
Discussion started by: nadeemrafikhan
10 Replies

4. Shell Programming and Scripting

Shell scripting issue-running the background script

I have written the below query to genrate a telephone.I am passing account number from oracle database. I am calling 2 scripts which generate the bill 1. bip.sh (it runs in the background) 2.runXitInvoice_PROFORMA_integ bip.sh generates a number which runXitInvoice_PROFORMA_integ uses.How... (7 Replies)
Discussion started by: rafa_fed2
7 Replies

5. Shell Programming and Scripting

Take minute per minute from a log awk

Hi, I've been trying to develop a script that performs the parsing of a log every 1 minute and then generating some statistics. I'm fairly new to programming and this is why I come to ask if I can lend a hand. this is my log: xxxx 16/04/2012 17:00:52 - xxxx714 - E234 - Time= 119 ms.... (8 Replies)
Discussion started by: jockx
8 Replies

6. Shell Programming and Scripting

Crontab for every minute or every hour

How to set crontab for every minute or every hour (1 Reply)
Discussion started by: kaushik02018
1 Replies

7. Shell Programming and Scripting

How do i get only last 5 minute worth of data

I have a text file called 'tomcat_temp_out'. I want to get only last 5 minute worth of data from this file and redirect those data into another fule. Could you please help to work on this? (2 Replies)
Discussion started by: shivanete
2 Replies

8. UNIX for Dummies Questions & Answers

perl scripting for checking if a process is running

Hi All, I am new to perl and have been trying to write a short script to check a process.Though i havent reached to the stage where i can match the output. I am trying to pass a variable x with value /opt/RGw/csbp-base/CSBP_BAT.01.00.05/csbp_BAT.01.00.05.jar and then pass another variable... (2 Replies)
Discussion started by: pistachio
2 Replies

9. Solaris

syslog messages every minute

Hi If we have for example a disk that is experiencing problems, ie read errors etc, a message will get generated via syslog every one minute....I come in the morning to hundreds upon hundreds of the same message. Is there anyway to change this to say 5 minutes or maybe 10 mins etc so that it... (1 Reply)
Discussion started by: hcclnoodles
1 Replies

10. Programming

linux 7.1 goes off every other minute

i have loaded linux 7.1 on my PC along with win98 the problem is that every other minute th system goes off please help me (1 Reply)
Discussion started by: vidya_harnal
1 Replies
Login or Register to Ask a Question