The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
problem with crontab cleansing_flame UNIX for Dummies Questions & Answers 1 01-29-2008 05:02 PM
Problem with crontab cleansing_flame UNIX for Dummies Questions & Answers 3 01-14-2008 01:03 PM
Crontab problem jess_t03 AIX 2 01-03-2008 04:29 AM
Problem with Crontab Zak UNIX for Dummies Questions & Answers 2 12-20-2005 02:44 AM
crontab problem DebianJ UNIX for Advanced & Expert Users 10 06-04-2005 12:36 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 09-15-2005
Registered User
 

Join Date: Sep 2005
Posts: 3
Problem with Crontab

I have a problem with crontab. I made a class file name Mailer.class. When I run it at command line like this:

$ java Mailer

It runs very well and I got the email. But If I put it in a crontab line like this:

30 11 * * * java Mailer

It doesn't work.

Every time the cron job finished, when I type something at command line, I got the "You have mail" sentence.

Please help me. I appreciate any help, comment

Thanks
Reply With Quote
Forum Sponsor
  #2  
Old 09-15-2005
Registered User
 

Join Date: Jan 2005
Posts: 682
You have probably lost your CLASSPATH environment variable using cron. Your .profile isn't getting launched in the non-inteactive shell that cron runs. Use -classpath and/or ensure you are setting up your environment using a shell script wrapper.

The mail message you are getting is no doubt related to the failed cron job.
Reply With Quote
  #3  
Old 09-15-2005
Registered User
 

Join Date: Sep 2005
Posts: 3
Thank you very much for a quick reply.

I have CLASSPATH environment variable in my .profile. And that is a long string. Do you have any link so I can learn how to set up environment using a shell script wrapper? Or can you give me some note about that?
I'm new to Unix. So please don't laugh at me...

Thanks again
Reply With Quote
  #4  
Old 09-15-2005
Registered User
 

Join Date: Jan 2005
Posts: 682
In the simplest form, create a shell script file called Mailer.sh:
Code:
#! /usr/bin/ksh

# Source your .profile parameters
. /home/youruserid/.profile

# or 
export CLASSPATH=yourreallylogclasspath

# add/modify more variables that you need

java Mailer
Make sure your script is executable:
Code:
chmod 755 Mailer.sh
Change your crontab entry to:
Code:
30 11 * * * /someUnixPathToYourScript/Mailer.sh
Reply With Quote
  #5  
Old 09-15-2005
Registered User
 

Join Date: Jan 2005
Posts: 682
This thread provides some helpful tips on determining whether or not your shell is interactive.
Reply With Quote
  #6  
Old 09-15-2005
Registered User
 

Join Date: Sep 2005
Posts: 3
Hi tmarikle,

Thank you very much for your help. It works very well!!!

I am really appreciate your help.

Quang
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:13 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0