The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script to move certain number of files every 10 minutes. amitsayshii UNIX for Dummies Questions & Answers 1 02-26-2007 04:55 AM
script to kill rsh processes running for more than 10 minutes amitsayshii Shell Programming and Scripting 1 06-27-2006 10:12 AM
script to kill rsh processes running for more than 10 minutes amitsayshii UNIX for Advanced & Expert Users 1 06-27-2006 10:07 AM
Convert minutes to hours, minutes, seconds Vozx Shell Programming and Scripting 1 12-09-2005 01:24 AM
C Shell Script to convert a number into minutes Ringo Shell Programming and Scripting 1 08-07-2003 01:24 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-04-2009
mrudula009 mrudula009 is offline
Registered User
  
 

Join Date: May 2009
Posts: 22
Script to run every 5 minutes

Hello all,

I want to run a script every 5 minutes. How to accomplish this task?


Thanks in advance
Mrudula
  #2 (permalink)  
Old 06-04-2009
robsonde robsonde is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 158
cron is your friend.

Cron from the name Chronos (the god of time)

The cron daemon is a long-running process that executes commands at specific dates and times. You can use this to schedule activities, either as one-time events or as recurring tasks


For commands that need to be executed repeatedly (e.g., hourly, daily, or weekly), you can use the crontab command.

The crontab command creates a crontab file containing commands and instructions for the cron daemon to execute. You can use the crontab command with the following options:

crontab filename installs a crontab from the file

crontab -e Edit your crontab file, or create one if it doesn't already exist.

crontab -l Display your crontab file.

A typical crontab will have system maintenance type tasks but any task can be put into cron.

Each entry in a crontab file consists of six fields, specifying in the following order:
minute(s) hour(s) day(s) month(s) weekday(s) command(s)

10 3 * * 0,4 /etc/cron.d/logchecker
10 3 * * 0 /usr/lib/newsyslog
15 3 * * 0 /usr/lib/fs/nfs/nfsfind
  #3 (permalink)  
Old 06-05-2009
mrudula009 mrudula009 is offline
Registered User
  
 

Join Date: May 2009
Posts: 22
Thanks for the wonderful explanation Rob !! Now lemme try to work it out ...
  #4 (permalink)  
Old 06-05-2009
diogooute diogooute is offline
Registered User
  
 

Join Date: May 2009
Posts: 11
To choice if you want to execute this script for everybody or for a specific user, that don't need to be the logged user like crontab -e, you can edit the file /etc/crontab. This file is similar similar, but there you have more one parameter, that is the user.
  #5 (permalink)  
Old 06-05-2009
mrudula009 mrudula009 is offline
Registered User
  
 

Join Date: May 2009
Posts: 22
I just tried a simple thing - to display time on the terminal every 5 minutes .. this is my crontab entry for it - but it doesnt seem to work ... y is that?

pwd
/usr/lib

contab -e
no crontab for root - using an empty one
crontab: installing new crontab

crontab -l
0,5,10,15,20 * * * * (echo -n ' '; date; echo " ") > /dev/console
  #6 (permalink)  
Old 06-05-2009
diogooute diogooute is offline
Registered User
  
 

Join Date: May 2009
Posts: 11
I guess yes...
Maybe no permission. If u syntax is wrong, its make a error in "crontab: installing new crontab".

To execute you script every 5 Min, you can use:

*/5 * * * * command
  #7 (permalink)  
Old 06-05-2009
shahnazurs shahnazurs is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 59
If I use,

*/5 * * * * /home/shahnaz/abc.sh >> /home/shahnaz/abc.log

I get an error saying like

crontab: error on previous line; unexpected character found in line.

Can you say why it was thrown such error?
Sponsored Links
Reply

Bookmarks

Tags
cron, crontab

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 07:38 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0