Skip to content

👷 Background Jobs

Some actions need to run continuously, such as running the API or syncing pipes in a loop. Rather than relying on systemd or cron, you can use the built-in jobs system.

👔 Jobs

All Meerschaum actions may be executed as background jobs by adding -d or --daemon flags or by prefacing the command with start job. New jobs will be given random names, and you can choose to specify a label with --name.

mrsm sync pipes -c plugin:foo --loop -d

Starting Jobs

Start a previous job by typing its name after start job[s]:

mrsm start job awake_sushi -y

Stopping Jobs

Stop a running job with stop job[s]:

mrsm stop job awake_sushi -y

You can stop and remove a job with delete job[s]:

mrsm delete job awake_sushi -y

⏲️ Schedules

You can run any command regularly with the flag -s or --schedule ― for example, -s hourly will execute the command once per hour. You can also specify a specific interval, e.g. -s 'every 10 seconds'. Here are a few of the supported frequencies:

  • every N [seconds | minutes | hours | days]
  • hourly
  • daily
  • monthly
  • daily starting 12:00
  • monthly starting 6th

Here is the complete documentation for the interval syntax.

mrsm sync pipes -m weather -s 'every 30 seconds' -d

🪵 Logs

You can monitor the status of jobs with show logs, which will follow the logs of running jobs.

mrsm show logs

You can attach to specific jobs by listing their names:

mrsm show logs awake_sushi my_job

You can get a plain printout by adding --nopretty:

mrsm show logs --nopretty