From: | Alan Hodgson <ahodgson(at)lists(dot)simkin(dot)ca> |
---|---|
To: | "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: How to run a task continuously in the background |
Date: | 2019-07-11 16:41:27 |
Message-ID: | 927408b7f1a964134cea896d86db41b1ea0bd5ff.camel@lists.simkin.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, 2019-07-11 at 11:19 -0500, Michael Nolan wrote:
> A cron job will only run once a minute, not wake up every second.
> But you could write a PHP program that does a one-second sleep before
> checking if there's something to do, and a batch job that runs
> periodically to see if the PHP program is running, and if not, launch
> it.
>
> That's how I handle a job that opens a tunnel from our PostgreSQL
> server to a MySQL server running at AWS so we can synchronize data
> between those two database servers. It dies periodically for reasons
> we've never figured out, so every 5 minutes I check to make sure it's
> running.
If you run such a job under systemd you can tell systemd to
automatically restart it if it dies.
Alternate, the application monit is an older means of monitoring and
restarting persistent processes, complete with email notifications.
This is quite a common system administration task. No need to roll your
own.
From | Date | Subject | |
---|---|---|---|
Next Message | Wayne Mell | 2019-07-11 20:04:34 | Postgresql and VBA - Connection Timeout |
Previous Message | Tim Clarke | 2019-07-11 16:33:28 | Re: Restore database into azure PostgreSQL |