• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

cron job

 
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
 
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.
 
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 ]
 
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
 
Everyone is a villain in someone else's story. Especially this devious tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!