Browse Docs

⏰ Jobs & Background

Schedule a task (at / batch)

1at      :  schedule a task to run at a later time (/!\ it executes what you give it on stdin).
2           ex :  at 18:22 < "date; ps -ef | wc -l"
3           or : at now + 5 hours  then type your commands then ctrl + d
4at -q a 16:05 tomorrow   :  -q defines the queue (a-z), i.e. the priority.
5at -c  <job_number>      :  see the context and the commands of the task.
6atq      :  list the pending jobs (= at -l).
7atrm     :  delete a job.
8
9batch   :  schedule a task when the load average is below a threshold.

Run jobs in the background

1jobs -l   : list the running tasks.
1# Nohup in series
2for i in {1..6}; do echo "nohup sh -c \"shred -vfz -n 3 /dev/cciss/c0d${i} > nohup${i}.out 2>&1 \" &" ; done | bash

Three points to remember:

  • Serial nohups cannot all write at once to the same default log (nohup.out): > nohup${i}.out 2>&1.
  • nohup does not support a for loop, so you have to generate the command with echo and redirect it to bash.
  • nohup for a long command: nohup sh -c "command with arguments".
1&          :  putting & at the end of a command lets you launch another without waiting for the first to finish.
2             ex : cp video.avi /users/user/desktop/copy-video.avi &.
3nohup      :  launches the program and keeps it running even once the console is closed (outputs 1&2 are redirected to nohup.out).
4ctrl + z   :  pause the current process.
5bg         :  move the paused process to the background.
6fg         :  resume a process in the foreground (if several run at once, fg %n).
7sleep      :  pause between the execution of two commands.
8             Example :  touch gt.txt && sleep 10 && rm gt.txt.
9             The pause is in seconds by default, but you can add a unit after the number: m, h, or d for minutes, hours, days.

Repeat a command (watch)

1watch  <cmd>  :  repeats a command every 2 sec. (-n X, to choose the interval)
2watch -d      :  repeats a command and only shows the difference between two results.
3watch -d 'ls -lrt'             :  watch whether files are created.
4watch -d 'ls -lrt | fgrep joe' :  watch whether files are created by the user joe.
Sunday, October 4, 2026 Monday, August 14, 2023