Running script file using cron job every 5 second


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Running script file using cron job every 5 second
# 1  
Old 05-18-2010
Bug Running script file using cron job every 5 second

Hi All,

I beginner in unix, i have no idea how to set the script file using cron job every 5 second. I also want to execute automatically the output to text file.This is my script name countsys.sh and my textfile abc.txt.
# 2  
Old 05-19-2010
Quote:
Originally Posted by mastercar
Hi All,

I beginner in unix, i have no idea how to set the script file using cron job every 5 second.
Minimum configuration in cron is minutes, you cannot set it for 5 seconds.


May be, invoke a script every minute, and then make that to execute the command for every 5 seconds for that one minute.
Quote:
Originally Posted by mastercar
I also want to execute automatically the output to text file.This is my script name countsys.sh and my textfile abc.txt.
Did you mean,

Code:
countsys.sh >> abc.txt

# 3  
Old 05-19-2010
In your script, you can use repeating loop and after ending the business logic use sleep 5.

After sleeping for 5 seconds, the script logic will be executed again. :-)

Hope it works for you !! The script will look somewhat like this..

while ( )
{
<business logic>
sleep 5
}

after this you can make this entry in cronjob and set it to execute on a particular time..

give a try ..
# 4  
Old 05-19-2010
Bug

Hi all,

I means that i want run my script automatically and the text file have been create also already update after the script finish to execute. So i dont type the script name example countsys.sh in command line.So the script automatically run and show the output in text file..I dont have any idea for do this, If you all have idea how to do please let me know....
# 5  
Old 05-19-2010
U can run ur script as below.
Open your crontab file and add the below lines to the file and save it.
It will do the required.

Code:
* * * * * /path where countsys.sh script exists/ >> /path for abc.txt
* * * * * /bin/sleep 5; /path where countsys.sh script exists/

Hope this works.
# 6  
Old 05-19-2010
hi nessj,

i have try it, but the text.file can't see when i use cat command.
Do you know what it means

countsys.sh[40]: abc.txt: Execute permission denied

hope you can give the answer...
# 7  
Old 05-19-2010
Quote:
Originally Posted by nessj
U can run ur script as below.
Open your crontab file and add the below lines to the file and save it.
It will do the required.

Code:
* * * * * /path where countsys.sh script exists/ >> /path for abc.txt
* * * * * /bin/sleep 5; /path where countsys.sh script exists/

Hope this works.

This will not work.
Moreover, there is no need to make use of cron here.

You can prepare a script which will run in an infinite loop, with a sleep of 5 seconds and run the script in the nohup.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Error while running a script through cron job

Hi Team, When i am running the below query manually it is giving me the right output i.e. export PATH=/usr/sbin:/usr/bin:/sbin:/bin:$PATH ADMIN=abc@abc.com CPU_HIGH=`sar|awk '{print $9}'|sort -n|head -5|sed -n 5p` CPU_MAX=`echo "scale=3; 100-$CPU_HIGH" | bc` CPU_LOW=`sar|awk '{print... (13 Replies)
Discussion started by: Ekamjot
13 Replies

2. Shell Programming and Scripting

CRON job still running?

Hi All, I am writing a script that will eventually be executed by a cron job every 15 minutes. I want to make sure that my logic/script doesn't get executed if a previous job is still running. What would be the best way to handle that scenario? I was thinking to make my script create a temporary... (1 Reply)
Discussion started by: rdogadin
1 Replies

3. Solaris

Cron job running even after cron is removed

Hi , I have removed a cron for particular user , but cron job seems to be running even after the cron entry is removed. The purpose of the cron was to sendmail to user ( it uses mailx utility ) I have restarted cron and sendmail service still user is getting mail alerts from the cron job. And... (4 Replies)
Discussion started by: chidori
4 Replies

4. Solaris

Cron job is not running

Hi, I have set up the crontab as follows. root@IDC4VASAPP07 # crontab -l 0-59 * * * * /var/tmp/r.sh 0-59 * * * * date >> /var/tmp/log root@IDC4VASAPP07 # r.sh is as follows. root@IDC4VASAPP07 # cat r.sh #!/bin/bash dt1=$(perl -e 'use POSIX;print strftime... (10 Replies)
Discussion started by: SunilB2011
10 Replies

5. UNIX for Dummies Questions & Answers

Cron is running,but my job is not triggering.

Hi, I have scheduled a job previously and was running fine,but due to some issue i have commented it.Now the issue was solved and i have scheduled as below in crontab. 30 2 * * * /u01/srcdata/CSA/holding/common/script/QPLR_RegValrao.sh PROD Cron is running,but my job is not triggering. ... (1 Reply)
Discussion started by: mvennakula
1 Replies

6. Shell Programming and Scripting

cron job and running program

Dear experts, I have this cronjob * */2 * * * $path/supervisor.sh The supervisor script is checking another script, which initializes the final scripts in multiple directories. Note that the supervisor script runs without the cronjob. In each directory, I have the following script: ... (2 Replies)
Discussion started by: TheTransporter
2 Replies

7. UNIX for Dummies Questions & Answers

Cron job not running

Hi All, I am editing crontab using -e option to add a new job Below is the line 30 * * * * scriptpath This job is not executing every thirty minutes. I have checked, cron daemon is running. What did I miss? Can some one help? I am using cron shell..ksh (7 Replies)
Discussion started by: yabhi_22
7 Replies

8. Shell Programming and Scripting

URGENT: cron job not running the sqlplus command in shell script

cron job not running the sqlplus command in shell script but the shell script works fine from command line.. Cronjob: 5 * * * * /home/dreg/script.sh script.sh: #!/bin/ksh /oracle/u000/app/oracle/product/10204/GEN/bin/sqlplus -s <user>/<pass>@<sid/home/dreg/sqlscript.sh ... (18 Replies)
Discussion started by: Ikea
18 Replies

9. UNIX for Advanced & Expert Users

cron job is not running

hi, i have the following line in the crontab 15 5 * * 6 /home/adw/BCE_ADW.pl The problem is the cron job is not getting started automatically. But this was working til last week. now it is not working. what could be the problem. Any idea? (3 Replies)
Discussion started by: Suguna
3 Replies

10. HP-UX

Cron Job Not Running

Hi, I have a cron schedule like this 04,16,28,40,52 * * * * /nag/startProcessABatch (unix script) i want to add new lines in this file (like Logging), i just copy this file into a /tmp folder (for backup copy), and i have edited this file (added few lines of code for logging). ... (1 Reply)
Discussion started by: nag_sundaram
1 Replies
Login or Register to Ask a Question