JamesR JamesR - 3 months ago 6x
Linux Question

Run JAR file at specific times daily with WinSCP

I am encountering a problem that I think there is a simple solution for. I'm currently using WinSCP (set up for FTP) with a Linux server for hosting a web application.

I've created a JAR file (

) that I can run manually in the WinSCP Console (
java -jar filename.jar
). It runs queries in a MySQL database that modifies an existing table. Effectively, for my front-end (that queries from this table) to be updated, it needs to have
file run twice daily.

I am wondering what the proper way to approach this is. Ideally, it would be done at 00:05 and 12:05 each day. If WinSCP can be configured to run
specifically at these times, that would be perfect. However, if there's a way to run the
continuously, I figure a while-loop verifying the desired system time within
would work as well.

I've seen lots of information on doing this locally, but found little to nothing helpful on doing this for a server. Thanks for any help or ideas in advance, let me know if I can improve this question or provide more information. If there are any resources that explain this clearly a link to those would be greatly appreciated as well. I'm a new WinSCP user, if you can't tell already.


As I mentioned in my comments, I think the easiest way is to make a cron job on the remote Linux server. You can edit the current cron table by using the crontab -e command. You can check out the cron format here or here.

In your case, it should look something like this:

5 */12 * * * java -jar /path/to/jarfile/filename.jar

This will run the java -jar ... command every 12 hours 5 minute.

After you save it, you can check the existing cron jobs with the crontab -l command. You can also check the syslog for the CRON entries, to see if the job works as intended.

cat /var/log/syslog | grep CRON