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.

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

Starting Jobs

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

1
mrsm start job awake_sushi -y

Stopping Jobs

Stop a running job with stop job[s]:

1
mrsm stop job awake_sushi -y

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

1
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.

1
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.

1
mrsm show logs

You can attach to specific jobs by listing their names:

1
mrsm show logs awake_sushi my_job

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

1
mrsm show logs --nopretty