UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 1st, 2004, 07:47 AM
shahrahulb shahrahulb is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 8 shahrahulb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry pls someone reply. cannot run cronjob

I have the following cron:

0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /v/sysadmin/sysnet/file.pl

The .pl has been tried at 755 and 777

The script works if manually run by the web browser or unix command prompt, but I can't get the Cron to do it automatically

i went thru the thread http://forums.devshed.com/archive/t-153308

it says "Solution: put the whole env. n the script."
i m using tcsh
what does this mean??

Thanks,
Rahul

Reply With Quote
  #2  
Old October 1st, 2004, 08:26 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,098 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 5 Days 8 h 44 m 33 sec
Reputation Power: 9
nobody will replay to this Q already discussed X000000 times
try to help your self.
man is a good friend, try: man man
btw: man is short for 'manual'

Reply With Quote
  #3  
Old October 1st, 2004, 08:37 AM
shahrahulb shahrahulb is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 8 shahrahulb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by guggach
nobody will replay to this Q already discussed X000000 times
try to help your self.
man is a good friend, try: man man
btw: man is short for 'manual'

I know. but it was running for more than a month and the cronjob stop running abruptly

pls help

Reply With Quote
  #4  
Old October 1st, 2004, 08:42 AM
andyb1ack andyb1ack is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 60 andyb1ack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 14 sec
Reputation Power: 5
When you login your environment is set (PATH, prompt, other parameters). You can see this with the env command.

You need to get this environment setup at the start of any jobs run from cron, otherwise they (probably) won't work or won't work as they did on the command line.

Reply With Quote
  #5  
Old October 1st, 2004, 08:50 AM
shahrahulb shahrahulb is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 8 shahrahulb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
andyblack

QUOTE=andyb1ack]When you login your environment is set (PATH, prompt, other parameters). You can see this with the env command.

You need to get this environment setup at the start of any jobs run from cron, otherwise they (probably) won't work or won't work as they did on the command line.[/QUOTE]



hi,

i understand ur point but where and how do i set the environment

following is my cronjob file: (name : temp_cron)
0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /u/rshah1/temp/test.pl

i did "crontab temp_cron".
now where should i set environment.
please give me complete command and location where to set

thanks,
rahul

Reply With Quote
  #6  
Old October 1st, 2004, 10:13 AM
andyb1ack andyb1ack is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 60 andyb1ack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 14 sec
Reputation Power: 5
You need to set the environment in the actual program that is going to run.

When running a shell script from cron you'd have commands at the top of the script to do this.

Check out post "Building a 'batch job' for crontab" by rct2dotcom. In it I've listed three ways you can do this:

Quote:
#!/usr/bin/ksh
#################################
# Filename: backup_webdb.ksh
# Description: Backup website database
#
# Revision history:
# 0.1 rc2dotcom Created
#################################

#-- Set your environment as cron won't pick it up

# Method1
PATH=/opt/bin:blah:blah
SOMEVAR=Production
otherstuff
# (dangerous if your environment changes and this code doesn't)

# Method2
. ~/.profile
# (better, but note it's korn shell specific -
# the .profile file in your home directory is "dotted" automatically when you login)

# Method3
. some_file_that_sets_the_environment
# (better still, especially if this file is "dotted" when you
# login and sets your environment at the command line)

#-- Do stuff
.
.
.


I've never written a perl script so don't know if you can set things like the PATH in it.

If you can't then you can always call the perl script from within a shell script...

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > pls someone reply. cannot run cronjob


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT