Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google site



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-09-2008
Registered User
 

Join Date: Nov 2008
Posts: 27
Cron Job Config files

Hi All,
I have created 2 shell scripts and set Cron jobs which runs it at various frequencies.The first one which runs every 2 minutes Monday to Friday and another cron job runs at 11PM on the last Sunday of every month. I have given the cron job entries below.

Was wondering whether instead hard coding the parameter values meant for the shell script in the crontab whether it was ok to set them as unix level environment variable or something and then use them instead in the cron job.

I think it will make the cron job make cleaner as well as more easily manageable.

My DBA says to use a “config” file to contain all the parameters that I need to pass on to the script

What are your thoughts on this?.If I have to go the config file way, what do i need to do as i have don't know much about creating/updating config files...

#======================================================================================
# CRON JOB FOR RUNNING THE SHELL SCRIPTS
#======================================================================================
# ------------- minute (0 - 59)
# | ----------- hour (0 - 23)
# | | --------- day of month (1 - 31)
# | | | ------- month (1 - 12)
# | | | | ----- day of week (0 - 6) (Sunday=0)
# | | | | |
*/2 * * * 1-5 sh SHELL1.ksh <PARAM1> <PARAM2> <PARAM3> <PARAM4> <PARAM5> <PARAM6> <PARAM7> <PARAM8> <PARAM9> <PARAM10> <PARAM11>
23 * * * 0 [`date "+%d"` -gt 24] && sh SHELL2.ksh <PARAM1> <PARAM2> <PARAM3> <PARAM4> <PARAM5> <PARAM6> <PARAM7> <PARAM8> <PARAM9> <PARAM10> <PARAM11>
Sponsored Links
  #2 (permalink)  
Old 12-09-2008
Registered User
 

Join Date: Jun 2008
Posts: 128
Just greate a file:
param1=value1
param2=value2
.....
source that file within your script
#!/bin/anyshell
......
. path/file

#and you can access the variables within your scripts
echo $param1
  #3 (permalink)  
Old 12-09-2008
Registered User
 

Join Date: Nov 2008
Posts: 27
Quote:
Originally Posted by demwz View Post
Just greate a file:
param1=value1
param2=value2
.....
source that file within your script
#!/bin/anyshell
......
. path/file

#and you can access the variables within your scripts
echo $param1

Hi,
thanks for the reply.I see what you are saying.But my issue is slightly different.My shell script takes 11 params and the shell script is run as a cron job.So instead of hard coding the values of the 11 parameters in the crontab file is there a way out to refer then from a file or something?..similar to the one you told me...such as setting the parameter values in the a cfg file and referring them in the crontab?
Thanks
  #4 (permalink)  
Old 12-09-2008
Registered User
 

Join Date: Nov 2008
Posts: 27
Ok.I have placed all the paremeters as variables in a filecalled as CONFIG.cfg and assigned them the relevant values.

Then I have added this portion to the top of my crontab
#! . /path/CONFIG.cfg

But my cron does'nt seem to run..I am very new to Unix so please bear my ignorance
  #5 (permalink)  
Old 12-10-2008
Registered User
 

Join Date: Jun 2008
Posts: 128
dont add the line to your crontab. add it to your scripts
  #6 (permalink)  
Old 12-10-2008
Registered User
 

Join Date: Nov 2008
Posts: 27
Hi,
thanks very much and it worked.
Now another question:

How do I migrate this crontab of mine across various environments?
My colleague says it has to be manually typed into various unix boxes.Can't we have a script/file that we can install or place in a certain path so that we can eliminate manual typing of crontab entries?

Thanks
V
Sponsored Links
Closed Thread

Bookmarks

Tags
shell script, shell scripting, unix scripting, unix scripting basics

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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Reuters Config Files - Where do they go? Linux Bot Complex Event Processing RSS News 0 11-14-2008 04:50 PM
bash: cron-config: command not found - PLEASE HELP ME!! sriya UNIX for Dummies Questions & Answers 2 10-14-2008 06:37 PM
Config Files toddjameslane HP-UX 0 05-19-2005 10:53 AM
Apache Config Files Webwitch UNIX for Dummies Questions & Answers 1 08-01-2001 04:35 PM
new LAN, where are the config files? softarch UNIX for Dummies Questions & Answers 3 03-27-2001 03:36 PM



All times are GMT -4. The time now is 05:39 PM.


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-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0