From: Alan Hodgson <ahodgson@lists.simkin.ca>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: How to run a task continuously in the background
Date: Thu, 11 Jul 2019 09:41:27 -0700
Message-ID: <927408b7f1a964134cea896d86db41b1ea0bd5ff.camel@lists.simkin.ca> (raw)
In-Reply-To: <CAOzAquKb+O3iu0pVBonDDSS8SH=a4Wa4hmYFxAbTwUCi7Hxjhg@mail.gmail.com>
References: <7932668C-EA48-436B-AA15-DB7C8446D57F@mikatiming.de>
<E9FA92C2921F31408041863B74EE4C2001BD810545@CCPMAILDAG03.cantab.local>
<CAOzAquKb+O3iu0pVBonDDSS8SH=a4Wa4hmYFxAbTwUCi7Hxjhg@mail.gmail.com>
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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: ahodgson@lists.simkin.ca
Subject: Re: How to run a task continuously in the background
In-Reply-To: <927408b7f1a964134cea896d86db41b1ea0bd5ff.camel@lists.simkin.ca>
References: <7932668C-EA48-436B-AA15-DB7C8446D57F@mikatiming.de> <E9FA92C2921F31408041863B74EE4C2001BD810545@CCPMAILDAG03.cantab.local> <CAOzAquKb+O3iu0pVBonDDSS8SH=a4Wa4hmYFxAbTwUCi7Hxjhg@mail.gmail.com> <927408b7f1a964134cea896d86db41b1ea0bd5ff.camel@lists.simkin.ca>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox