Linux Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsLinux 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:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old April 12th, 2008, 01:53 AM
smitanaik smitanaik is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 27 smitanaik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 28 m 30 sec
Reputation Power: 0
Proble in running shell script in cron

the syntax that i have used is

#! /bin/bash

javac Copy.java




#home/wbiadmin/JRE1.4.2/j2re1.4.2_15/bin/java Copy
/usr/bin/java Copy




this is my shell script
when i run it in terminal with command called ./runcopy.sh
it works fine



but when i run this shell script in cron it is not working.problem with java.lang


my cron is here:

1 * * /home/log/sari/./runcopy.sh


runcopy is shell script name.


help me out

Reply With Quote
  #2  
Old April 13th, 2008, 01:19 AM
Farcaster Farcaster is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 52 Farcaster User rank is Sergeant Major (2000 - 5000 Reputation Level)Farcaster User rank is Sergeant Major (2000 - 5000 Reputation Level)Farcaster User rank is Sergeant Major (2000 - 5000 Reputation Level)Farcaster User rank is Sergeant Major (2000 - 5000 Reputation Level)Farcaster User rank is Sergeant Major (2000 - 5000 Reputation Level)Farcaster User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 18 h 19 m 9 sec
Reputation Power: 46
Quote:
Originally Posted by smitanaik
the syntax that i have used is

#! /bin/bash

javac Copy.java

#home/wbiadmin/JRE1.4.2/j2re1.4.2_15/bin/java Copy
/usr/bin/java Copy

this is my shell script
when i run it in terminal with command called ./runcopy.sh
it works fine

but when i run this shell script in cron it is not working.problem with java.lang

my cron is here:

1 * * /home/log/sari/./runcopy.sh

runcopy is shell script name.


help me out


Your cron entry does not need - nor want - the ./ that you use from a command line. The ./runcopy.sh simply tells the shell to run the command from "here". That needs to be done since "here" is not always in your path - and that is a good thing.

So - in the cron entry you specify the full path to the script without the ./ prefix.

1 * * /home/log/sari/runcopy.sh

Cheers

Reply With Quote
  #3  
Old April 14th, 2008, 01:55 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Novice (500 - 999 posts) Click here for more information
 
Join Date: Mar 2006
Posts: 609 SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 8 m 27 sec
Reputation Power: 194
The dor may be a red herring, but it would be good to get rid of. I would further suspect that the PATH is not set up when being run via cron - you get a very basic PATH by default.
__________________
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer" - Bruce Graham

Reply With Quote
  #4  
Old April 15th, 2008, 01:53 AM
smitanaik smitanaik is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 27 smitanaik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 28 m 30 sec
Reputation Power: 0
#! /bin/bash



javac CopyFile.java
/usr/bin/java CopyFile



this is my shell script.when i call this script from terminal works fine.but through cron it gives me error saying exception i think it is not able to find the files that i have imported
such as
import java.io.*;
import java.util.*;
import java.lang.*;
import java.text.*;
import java.io.File;

help me out

Reply With Quote
  #5  
Old April 15th, 2008, 06:43 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Novice (500 - 999 posts) Click here for more information
 
Join Date: Mar 2006
Posts: 609 SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 8 m 27 sec
Reputation Power: 194
When I said PATH, I should have said your general environment!

Try putting a source (the . command) of your .profile (or .bashrc or whatever) at teh top of the script.

Reply With Quote
  #6  
Old April 15th, 2008, 07:24 AM
smitanaik smitanaik is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 27 smitanaik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 28 m 30 sec
Reputation Power: 0
#!/bin/bash

CLASSPATH=.
#CLASSPATH=${CLASSPATH}:${INSTALL_PATH}home/squidlog/CopyFile.java
CLASSPATH=${CLASSPATH}:${INSTALL_PATH}usr/java/latest/lib/*.jar

javac CopyFile.java


echo "CLASSPATH=$CLASSPATH"

#home/wbiadmin/JRE1.4.2/j2re1.4.2_15/bin/java CopyFile
/usr/bin/java CopyFile




i tried setting classpath still i have problem

Reply With Quote
  #7  
Old April 15th, 2008, 07:41 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Novice (500 - 999 posts) Click here for more information
 
Join Date: Mar 2006
Posts: 609 SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 8 m 27 sec
Reputation Power: 194
Out of interest, where is INSTALL_PATH defined?

Reply With Quote
  #8  
Old April 15th, 2008, 07:56 AM
smitanaik smitanaik is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 27 smitanaik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 28 m 30 sec
Reputation Power: 0
#! /bin/bash

CLASSPATH=.:usr/java/latest/lib/*.jar
javac CopyFile.java


echo "CLASSPATH=$CLASSPATH"

#home/wbiadmin/JRE1.4.2/j2re1.4.2_15/bin/java CopyFile
/usr/bin/java CopyFile

i tried likre this but still not working

Reply With Quote
  #9  
Old April 16th, 2008, 02:32 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Novice (500 - 999 posts) Click here for more information
 
Join Date: Mar 2006
Posts: 609 SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 8 m 27 sec
Reputation Power: 194
I really hate java ...
I still reckon it's your environment. Humour me? In your script, before you call the java put an env command, so your current environment is displayed. Run it by hand, then run it via cron and see what the difference is.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsLinux Help > Proble in running shell script in cron


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

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway