• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

cron job

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic