Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ignoring command exit code in linux

I have a Postgres console command createdb appname_production_master, which return error exit code if the database with this name already exists.

Is it possible to make this command do not return any exit code?

like image 811
Kir Avatar asked Feb 24 '12 16:02

Kir


People also ask

How do I ignore in Linux?

The signals 2 (SIGINT) , 3 (SIGQUIT) , and 20 (SIGTSTP) will be ignored by the shell process.

How do I ignore a bash output?

To silence the output of a command, we redirect either stdout or stderr — or both — to /dev/null. To select which stream to redirect, we need to provide the FD number to the redirection operator.

How do you exit a script if command fails?

Exit When Any Command Fails This can actually be done with a single line using the set builtin command with the -e option. Putting this at the top of a bash script will cause the script to exit if any commands return a non-zero exit code.

How do I stop a script in Linux terminal?

If you are executing a Bash script in your terminal and need to stop it before it exits on its own, you can use the Ctrl + C combination on your keyboard.


1 Answers

Just ignore the exit code, for example like this.

createdb appname_production_master || true
like image 51
tripleee Avatar answered Oct 12 '22 23:10

tripleee