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
cron tab setting Kbharat20 SUN Solaris 1 05-17-2008 12:48 AM
cron job setting jaydeep_sadaria Shell Programming and Scripting 2 11-21-2007 10:07 AM
Listing and setting up cron jobs NycUnxer UNIX for Dummies Questions & Answers 3 11-08-2007 09:45 PM
Setting environment variables within cron jobs!! atheek SUN Solaris 1 10-09-2006 08:26 AM
Cron not retaining TERM setting steelrose UNIX for Dummies Questions & Answers 2 10-14-2005 03:01 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-30-2008
tererez tererez is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1
Question setting a cron job

Greetings i am a newbie to this so kindly bear with me. I have a script to get weather information from a site and save that into a database.

Code:
wget Cranfield Weather Forecast
temp = $(cat wx.php | grep -o "Temperature.......")
rm wx.php
mysql -D "weather_wise" -e "insert into weather (date,hour,degrees) values (now(),now(),$temp)";
how would i set up a cron job for this given that i want:
0 00-23 * * 0-7 command ?

Last edited by Yogesh Sawant; 03-31-2008 at 12:01 PM.. Reason: added code tags
  #2 (permalink)  
Old 03-31-2008
manas_ranjan's Avatar
manas_ranjan manas_ranjan is offline
Registered User
  
 

Join Date: Jul 2007
Location: Amsterdam
Posts: 177
what is your condition to run the scripts.....e.g. when at what time the scripts needs to invoke.

before that check whether your cron deamon(crond) is running or not, if running setting up cron will not make an issue, if not then try to invoke that one , then set your cron, with absolute path, will work fine.
  #3 (permalink)  
Old 03-31-2008
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
this would help you
  #4 (permalink)  
Old 04-01-2008
preyan preyan is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 8
crons

User defined crons have to be created using the command crontab -e

set your cron accordingly

30 14 * * * <your file (eg.sh weather)>
| | | | |_____ Day of the week(0-6)
| | | |_______ Month (1-12)
| | |_________ Day of the Month (1-31)
| |___________ Hour of the Day (0-23)
|______________ Minutes (0-59)

cron start --start your cron
cron stop --stop your cron
  #5 (permalink)  
Old 04-01-2008
Tornado's Avatar
Tornado Tornado is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2006
Location: Melbourne
Posts: 249
I use this header at the top of the crontab file to make it easier when reading.
Code:
#Minute (0-59),
#|      Hour (0-23),
#|      |       Day of the month (1-31),
#|      |       |       Month of the year (1-12),
#|      |       |       |       Day of the week (0-6 with 0=Sunday).
#|      |       |       |       |       Commands
#|      |       |       |       |       |
#-------------------------------------------------------------------------------------------------------
So your crontab will look something like this:
Code:
# sudo crontab -l
#ident  "@(#)root       1.21    04/03/23 SMI"
#
# The root crontab should be used to perform accounting data collection.
#
#
#Minute (0-59),
#|      Hour (0-23),
#|      |       Day of the month (1-31),
#|      |       |       Month of the year (1-12),
#|      |       |       |       Day of the week (0-6 with 0=Sunday).
#|      |       |       |       |       Commands
#|      |       |       |       |       |
#-------------------------------------------------------------------------------------------------------
10      3       *       *       *       /usr/sbin/logadm
15      3       *       *       0       /usr/lib/fs/nfs/nfsfind
30      3       *       *       *       [ -x /usr/lib/gss/gsscred_clean ] && /usr/lib/gss/gsscred_clean
  #6 (permalink)  
Old 04-01-2008
stewarr stewarr is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 2
0 00-23 * * 0-7

Try 0-6 not 0-7?
  #7 (permalink)  
Old 04-01-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Help with wget
Help Inserting data in mysql table

Is that you, or does it just look a lot like you? Is this a homework assignment where all of you were directed to this site for help?

For what it's worth, those threads have more elegant solutions for getting the temperature from the web site. You should avoid using a temporary file, and you should avoid cat file | grep when just grep file works fine.
Closed Thread

Bookmarks

Tags
cron, wget

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 12:29 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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