Monday, 9 Feb 2026
Subscribe
logo
  • Global
  • AI
  • Cloud Computing
  • Edge Computing
  • Security
  • Investment
  • Sustainability
  • More
    • Colocation
    • Quantum Computing
    • Regulation & Policy
    • Infrastructure
    • Power & Cooling
    • Design
    • Innovations
    • Blog
Font ResizerAa
Data Center NewsData Center News
Search
  • Global
  • AI
  • Cloud Computing
  • Edge Computing
  • Security
  • Investment
  • Sustainability
  • More
    • Colocation
    • Quantum Computing
    • Regulation & Policy
    • Infrastructure
    • Power & Cooling
    • Design
    • Innovations
    • Blog
Have an existing account? Sign In
Follow US
© 2022 Foxiz News Network. Ruby Design Company. All Rights Reserved.
Data Center News > Blog > Global Market > Understanding exit codes on Linux
Global Market

Understanding exit codes on Linux

Last updated: October 5, 2024 2:58 am
Published October 5, 2024
Share
shutterstock 234875881 green fire exit sign against an indistinct soft white background
SHARE

Contents
Exit code numeric varyWrap-up
#!/bin/bash

checkParms

if [ $? != 0 ]; then
echo Exiting: checkParms failed
exit 1
fi

Remember that the exit code when a script ends will depend on the final command that’s run. The script beneath would finish with an exit code of 0 if the exit command weren’t included because the if/then command doesn’t generate any errors.

#!/bin/bash

contact /tmp/log 2> /dev/null

if [ $? -eq 0 ]
then
echo "File efficiently created"
else
echo "Couldn't create file"
exit 1
fi

Exit code numeric vary

The vary of values for exit codes runs from 0 to 255. If you happen to concern an “exit 256” command in a script after which examine the exit standing, you’ll discover that it’s equal to 0! For the reason that exit code is just going to occupy a single byte, you possibly can consider it as a modulo 256. “Exit 258”, equally, will go away you with an exit code of two.

Different particular exit codes embrace 2 (meant to point the misuse of a shell builtin), 127 (command not discovered), 128 (invalid exit code), an entire bunch of exit codes above 128 (128 + a sign for deadly errors) and 130 (management C deadly error). Exit code 1, alternatively, is a catchall for varied errors. If you wish to outline exit codes to point varied issues in your individual scripts, you’re in all probability higher off utilizing codes between 3 and 125 or, as has been recommended by some contributors to the furtherance of fine return code utilization, 64 to 113. In both case, you’ve got a variety of attainable return codes at your disposal. Standardizing on a set that fits your wants would possibly streamline your coding a bit.

See also  Understanding the 3D ice-printing process to create micro-scale structures

Right here’s an inventory of exit codes and the kinds of errors they characterize:

  • 0: Success. The command or script executed with none error.
  • 1: Basic error. The command or script failed for some unspecified cause (e.g., no such file).
  • 2:  This means misuse of a shell builtin, corresponding to passing an invalid possibility.
  • 126: Not executable
  • 127: Command not discovered
  • 128: Invalid argument to exit
  • 128+N: Deadly error sign N. The command or script was terminated by a sign N.
  • 130: Command terminated with ^C
  • 255: Exit standing out of vary. The command or script tried to exit with a worth higher than 255.

Wrap-up

Poorly written scripts could carry out some motion on behalf of the individual working the script after which blithely proceed on with out ever checking whether or not the motion taken was profitable. For instance, a script would possibly echo concern a sequence of “putting in …” messages with out ever checking whether or not the assorted packages that the script was meant to put in have been out there for putting in or whether or not the installations accomplished efficiently. Others exit with a non-zero standing code at any time when one thing goes flawed, however then ignore the resultant standing code when one script calls one other. The truth is, I’ve seen some scripts which concern “efficiently put in” messages regardless of the truth that the software program set up was something however profitable.

Source link

TAGGED: codes, exit, Linux, Understanding
Share This Article
Twitter Email Copy Link Print
Previous Article How open-source LLMs are disrupting cybersecurity at scale How open-source LLMs are disrupting cybersecurity at scale
Next Article Why MFA alone won't protect you in the age of adversarial AI Why MFA alone won’t protect you in the age of adversarial AI
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Your Trusted Source for Accurate and Timely Updates!

Our commitment to accuracy, impartiality, and delivering breaking news as it happens has earned us the trust of a vast audience. Stay ahead with real-time updates on the latest events, trends.
FacebookLike
TwitterFollow
InstagramFollow
YoutubeSubscribe
LinkedInFollow
MediumFollow
- Advertisement -
Ad image

Popular Posts

AWS Fastnet cable will expand cloud reach, but CIOs must read the fine print

Cloud suppliers dive deep Over the previous few years, the explosive progress in knowledge and…

November 12, 2025

Asperitas secures fresh new investment for scale-up phase

Asperitas has closed a scale-up funding spherical of an undisclosed quantity to help worldwide growth…

September 9, 2025

10 cloud development gotchas to watch out for

The advantages of growing software program within the cloud embrace elevated flexibility and reliability, better effectivity,…

March 26, 2024

Linus Raises $5M in Seed Funding

Linus, an Oakland, CA-based SAT prep startup, raised $5M in Seed funding. The spherical was…

April 7, 2025

Sandbox Wealth Closes $1.25M in Pre-Seed Funding

Sandbox Wealth, a NYC-based supplier of a banking answer for non-bank monetary establishments, raised $1.25M…

December 4, 2024

You Might Also Like

RAM memory stick module exposed and sitting on a circuit board
Global Market

Intel teams with SoftBank to develop new memory type

By saad
Can air cooling survive the AI era?
Global Market

Can air cooling survive the AI era?

By saad
System administrator typing supercomputer hub disaster recovery plan on laptop to provide fast restoration of service, limiting damage and minimizing interruptions to normal operations
Global Market

8 hot networking trends for 2026

By saad
Shutterstock Germany Only - News - Intel Factory Germany September 2024
Global Market

Intel sets sights on data center GPUs amid AI-driven infrastructure shifts

By saad
Data Center News
Facebook Twitter Youtube Instagram Linkedin

About US

Data Center News: Stay informed on the pulse of data centers. Latest updates, tech trends, and industry insights—all in one place. Elevate your data infrastructure knowledge.

Top Categories
  • Global Market
  • Infrastructure
  • Innovations
  • Investments
Usefull Links
  • Home
  • Contact
  • Privacy Policy
  • Terms & Conditions

© 2024 – datacenternews.tech – All rights reserved

Welcome Back!

Sign in to your account

Lost your password?
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.
You can revoke your consent any time using the Revoke consent button.