Run an action every 30 seconds

Hello,
I would like my Nginx server to run every 30 seconds a service job. This
job will just send a message to another server that the nginx is running
and OK. Does anybody know how to do it?
I have just one idea - to write a module that will send the OK message
to another server. Then cron will run each 1 minute (unfortunately 30
seconds is not possible) a script that will send a request to the
module.

Thanks in advance for your ideas,
Michal

Posted at Nginx Forum:

how about linux crond?i think it will be much easier than moudle.

在 2011-2-8 下午6:37,“michalkraus” [email protected]写道:

Michal

Posted at Nginx Forum:
run an action every 30 seconds

Two options:

  1. Use cron if you can accept minimum 1 minute between every launch.
  2. Use a a script with a sleep() instruction and verify that the script
    is
    always running.
  3. Use a heartbeat solution - http://linux-ha.org/wiki/Main_Page
  • Gregory

2011/2/8 baalchina [email protected]

Three options:

  1. Cron if you can wait 1 minute.
  2. Script always running with sleep() instruction and check that the
    script
    is always running.
  3. HA/Heartbeat - http://linux-ha.org/wiki/Main_Page
  • Gregory

2011/2/8 baalchina [email protected]

On 08/02/11 11:05, Gregory Agerba wrote:

Two options:

  1. Use cron if you can accept minimum 1 minute between every launch.
  2. Use a a script with a sleep() instruction and verify that the script is
    always running.
  3. Use a heartbeat solution - http://linux-ha.org/wiki/Main_Page
  1. Use cron to start a script which does the test, sleeps for 30s, then
    does
    the test again, then dies (to be restarted by cron at the next minute)


Mark Rogers // More Solutions Ltd (Peterborough Office) // 0844 251 1450
Registered in England (0456 0902) @ 13 Clarke Rd, Milton Keynes, MK1 1LG

Thanks for your options

  1. Use a heartbeat solution - http://linux-ha.org/wiki/Main_Page

I have API between the Nginx and the second (control) server. I use RPC
interface. I need just send a RPC request (with status infrmation) to
the control server. I think that heartbeat is too robust.

  1. Use cron to start a script which does the test, sleeps for 30s,
    then does
    the test again, then dies (to be restarted by cron
    at the next minute)

This option seems to be the best but is any possibility the nginx to do
it in its own?

Posted at Nginx Forum:

On 8 Fev 2011 10h37 WET, [email protected] wrote:

Hello, I would like my Nginx server to run every 30 seconds a
service job. This job will just send a message to another server
that the nginx is running and OK. Does anybody know how to do it? I
have just one idea - to write a module that will send the OK message
to another server. Then cron will run each 1 minute (unfortunately
30 seconds is not possible) a script that will send a request to the
module.

Use the HTTP Echo Module | NGINX and a cron job that
checks a certain location and posts the message you wnat using curl to
the other server.

Just an idea

— appa

server {
listen 8082;
server_name localhost;

    location = /a-help2 {
        content_by_lua 'ngx.say(ngx.time())';
    }
    location = /a-help {
        proxy_pass http://127.0.0.1:8082/a-help2;
    }
    location = /a {
        echo_location /a-help;
        echo_sleep 2;
        echo_location /a-help;
    }
}

start a cron job to curl localhost:8082/a
just a sample conf.

require nginx-echo module( GitHub - openresty/echo-nginx-module: An Nginx module for bringing the power of "echo", "sleep", "time" and more to Nginx's config file
)

On Tue, Feb 8, 2011 at 7:35 PM, michalkraus [email protected]
wrote:

the test again, then dies (to be restarted by cron
[email protected]
nginx Info Page


Regards,

林青(Kindy Lin)