title: How to run Postgres pg_cron Job AFTER another Job?
body: <p>I running some automated tasks on my postgres database at night using the pg_cron extension. I am moving certain old records to archive database tables. I am running 5 Stored Procedures <em>concurrently</em> on 5 different background workers, so they all start at the same time and run on different workers (I am assuming this is similar to running different Tasks on different Threads in Java). These 5 Stored Procedures are independent (moving records to archive tables), so they can run at the same time. I schedule them each using a command like</p>
  <pre><code>cron.schedule (myJob1,
      '* * * * *',
      'call my_stored_proc_1()'
  );
  
  cron.schedule (myJob2,
      '* * * * *',
      'call my_stored_proc_2()'
  );
  
  .
  ..
  ...
  
  cron.schedule (myJob5,
      '* * * * *',
      'call my_stored_proc_5()'
  );
  </code></pre>
  <p><em><strong>NOW, I have some MORE</strong></em> <strong>dependent</strong> Store Procedures that I want to run. But they need to run AFTER these 5 Jobs finish/complete, because they are doing some <strong>DELETE</strong>... sql operations.</p>
  <p><strong>How can I have this second Stored Procedure (the one doing the DELETE queries) Job run AFTER my first 5 Stored Procedures Jobs when they are DONE?</strong> I don't want to set a CRON expression for the second Stored Procedure doing the DELETES, because I don't know what time the first 5 Stored Procs are even going to finish...</p>
  <p>Below I included a little schematic of how the Jobs are currently triggered and how I want it to work (if possible):
  <a href="https://i.stack.imgur.com/OzsDT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OzsDT.png" alt="enter image description here" /></a></p>