How do I check output of salt command that runs in background?

I've got a salt script written by someone else that is executing a bunch of commands. It runs for a very long time. My connection to the machine that runs it broke, but it is still running. How do I get back to it to see what it does? I did not start it using screen.

Here's what the command looks like:

$ salt --subset=1 -C 'G@application:foo and G@roles:application and G@vpc:staging' state.sls foo.commands.application.export

There are a bunch of hosts that have the role application and that stuff is working well. I am monitoring the output of what this is doing (pushing to a queue) somewhere else.

I believe I am looking for some sort of "check the status of a running salt script" but could not find that in the documentation.

I'm running salt 2014.1.13 (Hydrogen) on Ubuntu 14.04.1 LTS.


Solution 1:

Use the job cache.

First list recent jobs with jobs.active or jobs.list_jobs.

$ sudo salt-run jobs.list_jobs
Note I've only included one entry here

'20141204125446199193':
  Arguments:
  - salt-ssh production cmd.run_all bash /home/Administrator/bin/weekly-product-build.sh
  Function: cmd.run_all
  StartTime: 2014, Dec 04 12:54:46.199193
  Target: lead
  Target-type: glob
  User: root

Then get the returned output for a particular jid:

$ sudo salt-run jobs.lookup_jid 20141204125446199193 | head -22

lead:
    ----------
    pid:
        2301
    retcode:
        0
    stderr:

    stdout:
        production:
            ----------
            pid:
                688
            retcode:
                1
            stderr:
                + case $(date +%a) in
                ++ date +%a
                ++ date -d Thursday +%F
                + TARGET_DATE=2014-12-04
                ++ date -d 2014-12-04 +%Y%m%d
                + ymd=20141204