Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can a cron job call a servlet?

 
Chris Montgomery
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if so, how?
I've never done a cron job before...

right now, I have a file called Email and I've placed it in my /etc/crod.d directory to be called once a minute.

here are the contents of my Email file:
GET use http://192.168.100.23:8080/Email/EmailServlet

but nothing appears to be happening.

Thanks!
 
Gonzalo Nadal
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi chris,
I made a file call runTest.sh, marked as executable, and it works.


#! /bin/sh

GET www.google.com

[ December 11, 2005: Message edited by: Gonzalo Nadal ]
 
Chris Montgomery
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay, now I have:

#! /bin/sh
GET 192.168.100.23:8080/Email/EmailServlet

but still don't see it.

The way I am able to tell is through logging. When I visit it using a browser, I get a row in my log table.

I don't see any rows being added. I'm going to my services and restarting crond.

Is it a port issue?
 
Gonzalo Nadal
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well.

Try to invoke directly the script from a command line and see if your servlet is called.
If the servlet is called the problem is in the cron configuration.

If the servlet is not called from command line then will be a bit harder find the problem.

The servlet receive any parameters?
The url that you invoke from browser is the same in the script?
 
Peter Rooke
Ranch Hand
Posts: 848
1
Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The may be of interest: jCronTab. Never used it, could you tell us if you find it useful.

You might find this site helpfull: JPackage - once you have the required update manager installed and configured - you can download the lastest open source java / j2ee tools without having to worry about package dependancies.
[ December 11, 2005: Message edited by: Peter Rooke ]
 
Chris Montgomery
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getting closer. When I tried running it I received a Permission denied error. I ran a chmod on it, but as of now it's only set for user root and group root.

The job still isn't running.

What user "owns" cron jobs?
 
Chris Montgomery
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
got it. seesm cron.d isn't the way to go. I put the line in my crontab file and it worked perfectly.

Thanks for the help
 
Gonzalo Nadal
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great!
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cron.d entries must be marked executable or they get ignored. In the RdHat/Fedora Vixie cron, you place the script in question (or a link to it, anyway) in the cron.daily, cron.hourly, cron.weekly or whatever directory.

Cron normally will email its results to you.

There are two different cron interfaces, BTW. the /etc/cron.d stuff is run as root, which is not recommended for user-level jobs.

For userlevel jobs, each user has a crontab that can be edited. For details I'll have to refer you to the crontab man pages, though. It's been a while.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cron normally doesn't know the environmentsettings from /etc/profile, /etc/bash.bashrc or whatever is used on your machine.

So instead of wget, you have to call /usr/bin/wget with the full path or which path is needed in your case (I don't know GET).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic