0

I have added a git pull & to my bashrc to keep a particular project always up to date!

However this means every time I open a terminal I get a message like

[17]+ Running git pull

And a few seconds later

[17] Done

Is there a way to stop this output? I'm already sending all output to dev null so the full command is git pull >/dev/null 2>&1 &

Pez Cuckow
  • 525
  • 3
  • 8
  • 22

5 Answers5

2

The messages on screen are the result of backgrounding the job, not the job itself.

Try this:

#!/bin/bash

exec &> /dev/null
git pull

In this variant, the process backgrounding the job is a script that already redirects all output.

Of course, such a command should really go in your bash_login, or in your .profile, not in .bashrc.

adaptr
  • 16,576
  • 23
  • 34
0

You could use at(1) or even batch(1) to start your command:

echo git pull | at now 2>/dev/null

This way it would also not receive a SIGHUP if you log out immediately. The 2>/dev/null prevents the message job 1334584295.a at Mon Apr 16 15:51:35 2012 to be written by the at command.

You may have to add your user name to /usr/lib/cron/at.allow (location of this file may differ with our flavour of UNIX/Linux).

ktf
  • 194
  • 3
0

Use a subshell and mute STDOUT and STDERR:

(&>/dev/null git pull &)
Tom Hale
  • 1,105
  • 1
  • 12
  • 24
0

use nohup:

nohup git pull &
Jonas Bjork
  • 386
  • 1
  • 4
-1

I found that using a subshell silences the backgrounding of the job:

(git pull &)
Fabien
  • 1