Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cron job

 
Prashanth Chandra
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need to write a cron job script which automatically updates the values in the databse without anyone's intervention. I am pretty new to this concept and I have got no idea of how to write a script of cron job.


Thanks in advance
regards
 
Gerardo Tasistro
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well a cron job is just like any other script except you call it from a cron file using the "crontab -e" command.

For example

*/10 * * * * /usr/local/bin/domything

will run the domything script every 10 minutes. The little asteriscs stand for minutes, hours, days, months and days of the week. A more detailed usage can be found here

http://www.phpfreaks.com/tutorials/28/0.php

After the asteriscs you can call anything and use semicolon ; to separate various commands.
 
Don Morgan
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Write your database update as a regular script (which, of course can call other java programs to actually to do the update or use something like isql) and then all you use cron for is to schedule the execution of that script. Once you have your script written, it is a simple step to add it to cron. Take a look at the man pages for cron or ask your sysadmin.
[ January 10, 2006: Message edited by: Don Morgan ]
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "script" does not have to be a shell script. It can be any executable program written in any language that you choose. cron just schedules when it should be run. I think you could make it as a Java application. The only caveat I can see is that cron might not like running something like "java MyApp", so you may need a shell script with just one line to launch your Java app.

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic