Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash "&" without printing "[1]+ Done "

I call a script in my .bashrc to print number of new messages I have when I open the terminal, I want the call to be non blocking as it accesses the network and sometimes takes a few seconds which means I can't use the terminal until it completes.

However if I put:

    mailcheck & 

in my bashrc, it works fine. but then prints an empty line and I have when I press enter and it prints

    [1]+  Done                    ~/bin/mailcheck

This is very messy is there a way around this?

like image 675
Richard Mosse Avatar asked May 03 '12 21:05

Richard Mosse


People also ask

What does Bash mean?

As explained in the Bash Reference Manual, the name bash is an acronym of "Bourne-again SHell" which is a pun on Stephen Bourne, author of the Bourne shell. Bash is a superset of the earlier shell, and generally compatible with Bourne shell programs.

What is Bash used for?

Bash or Shell is a command line tool that is used in open science to efficiently manipulate files and directories.

Is Bash still used?

The biggest advantage to learning Bash is that it's so widely used. Even if you're working in another programming language like Python or Ruby, it's worth learning Bash because many languages support Bash commands to pass data and information to and from your computer's OS.

Is Bash a Windows or Linux?

Note that bash runs natively on Windows 10, which is different from using emulators like 'cygwin' for Windows which enabled GNU tools to run on unsupported Windows environment. Also, Linux subsystem for Windows 10 is only available on the 64-bit version of the OS.


3 Answers

That message isn't coming from mailcheck, it's from bash's job control telling you about your backgrounded job. The way to avoid it is to tell bash you don't want it managed by job control:

mailcheck &
disown $!
like image 184
Gordon Davisson Avatar answered Oct 03 '22 01:10

Gordon Davisson


This seems to work:

(mailcheck &)
like image 25
Paul R Avatar answered Oct 03 '22 01:10

Paul R


You can call your script like this:

(exec mailcheck & )
like image 28
anubhava Avatar answered Oct 03 '22 00:10

anubhava