Removing all at jobs except the ones running?

Karl Auer kauer at biplane.com.au
Mon Mar 7 09:11:18 UTC 2022


On Mon, 2022-03-07 at 09:12 +0100, Bo Berglund wrote:
> I am scheduling jobs to be executed using at and this works fine
> mostly.
> 
> But sometimes I want to reset the at job list and I have found this
> command to
> ease this when the at job list is long:
> 
> atq | cut -f 1 | xargs atrm
> [...]
> But since atq lists also the *running* jobs it will attempt to remove
> also these, which I don't want.
> How can I exclude running jobs from removal while still being able to
> remove all queued jobs easily?

atq lists all jobs by default, but you can limit the output to a named
queue. If you specify the special queue-name "=" it will list only
running jobs. So if you combine the list of all jobs and the list of
running jobs, then use sort and "uniq -u" to remove any jobs that
appear twice, you should get a list of non-running jobs that you can
pump into xargs.

Of course, any job can go from running to non-running at any moment, or
vice versa.

Be warned that I have not tried this myself!

Regards, K.


-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl Auer (kauer at biplane.com.au)
http://www.biplane.com.au/kauer

GPG fingerprint: 61A0 99A9 8823 3A75 871E 5D90 BADB B237 260C 9C58
Old fingerprint: 2561 E9EC D868 E73C 8AF1 49CF EE50 4B1D CCA1 5170







More information about the ubuntu-users mailing list