0

I have a project, i need to do this

  1. a desktop application sends a txt file with a number to the web server every 5 seconds
  2. the web server opens that file and saves the number in a database

the thing is that i need it to work 24/7 , even if the user hasn't logged in.

the desktop application already works, what can I do?

John Carter
  • 50,377
  • 25
  • 100
  • 137

3 Answers3

2

You should use a cron to do this. Here's an article explaining how to set them up in linux: http://kevin.vanzonneveld.net/techblog/article/schedule_tasks_on_linux_using_crontab/

In case you're running this on windows: What is the Windows version of cron?

Mac is similar to linux: http://benr75.com/pages/using_crontab_mac_os_x_unix_linux

Community
  • 1
  • 1
c.hill
  • 2,737
  • 22
  • 30
0

use Unix Chron to plan a php job that fits your needs

Sebas
  • 19,640
  • 9
  • 48
  • 103
0

What you're trying to do is not actually a web server function, per se, (there isn't a request to serve) you just want to run a PHP script on a pre-determined schedule. To do that, you should run a scheduled job (cron on non-windows, Scheduled Task on Windows).

We use Windows, so here's how you set up a scheduled task for a php script to run when you need it to:

  1. On the web server, from Control Panel, create a new Schedule Task
  2. Set the Run value to wherever PHP is installed and the script you want to run:

    "C:\Program Files\Php5\php.exe" C:\webserver\scripts\myphpfile.php

  3. Set the Start in to wherever your php file is:

    C:\webserver\scripts\

  4. Set up the rest of the Schedule Task options to your needs.

GDP
  • 7,641
  • 6
  • 40
  • 73