3 usage_help_text
="qls [<OPTIONS>] [<ID>]
4 List items in the queue, or show a particular task's details if <ID> is given.
7 ADDED when the task was added
8 STATE queued, running, ended, ended(<CODE>), gone
9 COMMAND command to run, shown either in multiple lines (2nd and following lines prepended by TABs)
10 or in a single line with backslash and newline chars escaped by backslash
14 -M, --no-multiline, --escape-command
17 -h, --hide-state <STATE>
22 qls_show_exit_status
=''
30 echo "qls: $queue_dir" >&2
37 itemfile
=$queue_dir/$item_id.
comm
38 load_command_global
"$itemfile"
40 declare -p command | cut
-d= -f2-
42 state
=`qtask_state "$item_id"`
45 pidfile
=$queue_dir/$item_id.pid
48 pid
=`cat "$pidfile" 2>/dev/null`
50 task_pidns
=`cat "$queue_dir/$item_id.pidns" 2>/dev/null`
51 curr_pidns
=`readlink /proc/self/ns/pid`
52 if [ "$task_pidns" != "$curr_pidns" ]; then echo " pidns=${task_pidns#*:}"; else echo; fi
54 timestamp
=`stat -c %Y "$itemfile"`
55 datetime
=`date +"%F %T" -d @$timestamp`
56 echo "Added: $datetime"
58 timestamp
=`stat -c %Y "$pidfile"`
59 datetime
=`date +"%F %T" -d @$timestamp`
60 echo "Started: $datetime"
64 load_command_global
"/proc/$pid/cmdline"
66 declare -p command | cut
-d= -f2-
67 process_status
=`grep "^State:" /proc/$pid/status 2>/dev/null | sed -e 's/^[^:]\+:\s*//'`
68 echo "Process Status: $process_status"
72 endfile
=$queue_dir/$item_id.end
75 timestamp
=`stat -c %Y "$endfile"`
76 datetime
=`date +"%F %T" -d @$timestamp`
77 echo "Ended: $datetime"
80 echo "Returned: $code"
89 echo "ID ADDED STATE COMMAND"
94 for itemfile
in "$queue_dir"/?.
comm "$queue_dir"/??.
comm "$queue_dir"/???.
comm "$queue_dir"/????.
comm "$queue_dir"/?????.
comm "$queue_dir"/??????.
comm "$queue_dir"/???????.
comm
96 item_id
=`basename "$itemfile" .comm`
97 state
=`qtask_state "$item_id"`
100 if grep -qw "$state" <<< "$qls_hide_states"
105 timestamp
=`stat -c %Y "$itemfile"`
106 datetime
=`date +"%F %T" -d @$timestamp`
107 load_command_global
"$itemfile"
108 command_str
=${command[*]}
110 if [ $qls_show_exit_status ]
112 if [ "$state" = ended
]
114 code
=`cat "$queue_dir/$item_id.end"`
116 state_shown
="$state($code)"
120 if [ $qls_multiline ]
122 command_shown
=${command_str//$'\n'/$'\n\t\t\t'}
124 command_shown
=${command_str//\\/\\\\}
125 command_shown
=${command_shown//$'\n'/\\n}
128 echo "$item_id $datetime $state_shown $command_shown"