When I run:

watch 'cmd >> output.txt' &

the job gets suspended by the system:

3569 Stopped (tty output)

Is there a workaround?

10 Answers 10


The purpose of watch is to show the results of a command full-screen and update continuously; if you're redirecting the output into a file and backgrounding it there's really no reason to use watch in the first place.

If you want to just run a command over and over again with a delay (watch waits two seconds by default), you can use something like this:

while true; do
    cmd >> output.txt
    sleep 2
  • 1
    Is there a way to do this in a non-blocking fashion though? For example if I want to put this and other commands in a single bash script, and have it continue to run the code that comes after this (while still doing this in the background)?
    – Austin
    Apr 5, 2019 at 21:18
  • 1
    The use case for watch in the background is running multiple things periodically on different schedules. A loop will not easily accomplish this.
    – kevinc
    Apr 19, 2020 at 0:40

Update, thanks to @SDK:

watch -n 1 'date | tee -a output.txt' &>/dev/null &

tee is incredibly useful and will push the output to the file specified.

Previous Answer:

Here's a way:

watch -n 1 'date' &>/dev/null &

Since you background the process, we can assume you don't need the terminal display and you are fine redirecting to a file. If you do that you will be able to background watch without issue.

sleep, as suggested by Michael Mrozek, will slowly lag which can be undesirable. Aside from a convoluted shell script that monitors system time and executes a command based upon elapsed time, watch -p can be a good option for precise timings.

For precise timings:

watch -n 1 -p 'date' &>/dev/null &
  • 1
    sorry, how does this work? why is it possible to just use & two times?
    – phil294
    Dec 16, 2017 at 18:52
  • 1
    Read the pipeline section of man bash to see how the first & works. ;)
    – Mio Rin
    Jul 21, 2018 at 17:25

I'm not sure about your motivations, but maybe this would be enough?

while true; do sleep 2; cmd >>output.txt; done &

Otherwise, please explain why you really need watch.

  • clever solution without watch command but functionally solving the request
    – Cris
    Sep 24, 2022 at 20:15

tee is your friend. For example, here's how you could show the number of files in the current directory, and append it to count.txt every 2 seconds:

watch 'find . -maxdepth 1 -printf " " | wc -c | tee --append count.txt'

Depends on your motivations:

  • You want to run something periodically. Then you could use directly cron. (If a time granularity of 1 minute is enough for your purposes).

    • Note: If the interval is very short or the device is very constrained, and unless you configure syslog to log less messages from crond, it will fill up your syslog pretty quickly.
  • You want to just run something repeatedly:

    while sleep 2 ; do
    done >& log.txt

    (You can run this from the crontab for example, although using a script is highly recommended).

  • You want to run periodically a command and have access to the output of its last execution.

    • You can write the output to a ramfs (modifying the script before):

      while sleep 2 ; do
        cmd >& last_execution.log

      or even better:

      while sleep 2 ; do
        cmd >& last_execution.log.tmp 
        mv last_execution.log.tmp last_execution.log ## atomically
    • You can combine screen and watch, so that you can always check the latest status, as long as it fits in one screenful:

      screen watch -n 3660 ./make-backup.sh

You can use screen command.


  • with screen you can create a background terminal session, close it and open when you need it.
    – Roberto
    Sep 27, 2011 at 12:13

If you must use watch - Just combine answers from mike dangelo and l0b0

watch -n 1 'cmd | tee -a output.txt' &>/dev/null &


watch -n 1 'date | tee -a output.txt' &>/dev/null &

then watch the seconds go by

tail -f output.txt

Watch is designed to output to the screen, but it's output can be redirected (both stdout and stderr) then it will run in the background.

watch 'date >>fa' >/dev/null 2>/dev/null &

nohup watch 'cmd >> output.txt' &

This is the simplest and most working solution.


so, this works

watch -tg 'grep Hello ./helloWorldOut.txt' >/dev/null

as in not clearing the screen and returning your cursor when it is complete - but it also calls into question why you are using watch. The command is designed to be visual, so you can't miss it. Perhaps your need is not what they created this command for. Just open a second terminal session (you should have two open anyway,) and run either the watch command you need or a quick cli while loop to do what you need, but running it as a bg job is really pushing it (what the command is there for) all the way to the side...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .