Entity Opt Dell

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Friday, August 30, 2013

Bash : Wait for a command with timeout

Posted on 3:50 AM by Unknown
Here is a very useful little command that wait for a process to finish and kill it if doesn't exit after a pre defined timeout.

The command is called timeout and is part of the coreutils package witch is embedded by default in CentOS 6.

Usage is very simple, you just need to specify the timeout, the process to start and optionally the signal to send in case of failure.

Timeout returns the exit value of the process and if the timeout has been reached, the value 124 is returned.

Here are some examples on how to use timeout :

Successful process : 
 $ timeout 10s ls /tmp  
....
....
$ echo $?
0

Unsuccessful process :
 $ timeout 10s ls /blabla  
ls: cannot access /blabla: No such file or directory
$ echo $?
2

Timed out process :
 $ timeout 5s sleep 10  
$ echo $?
124

More details in the man page.

Hope that helps !
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in Bash, CentOS, Linux, Script, Shell, System | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • omreport : failed to load external entity "/opt/dell/srvadmin/var/lib/openmanage/xslroot//oma/cli/about.xsl"
    If you're having the following error when executing omreport : I/O warning : failed to load external entity "/opt/dell/srvadmin/va...
  • Fixing the "ExSec32.dll is incompatible with Microsoft Outlook" Error
    The Problem I had a user who the the following error on the computer "The file ExSec32.dll is incompatible with Microsoft Outlook. Inst...
  • Juniper JunOS transfer on commit fails
    I had quite a surprise when I discover that my transfer on commit stopped working on my SRX firewall. The error in the logfile was : ACCT_X...
  • Enable LDAP SSL/TLS user authentification in Zabbix
    By default Zabbix Web interface doesn't offer the SSL/TLS encryption option for the LDAP connector however the feature is available in t...
  • Easy way to find your public IP in scripts or CLI
    There is a lot of online tools that gives your public IP but most of them are either not accepting cli User-Agent or they requires nasty par...
  • Whitelist files with Clamav
    Exclude files from scan : Sometimes, you will need to whitelist files from a scan, clamscan offers the --exclude option but its usage is not...
  • Windows Update Failing with Error 80243004
    The Problem I have 8 computers that due to the software they have on them I must some and update them manually once a month. Upon doing this...
  • Remote Assistance, VNC, and UAC Prompts
    Intro Many of us as tech professionals are quite busy and reducing time doing unnecessary tasks is necessary so we can still complete the ev...
  • Bash : Wait for a command with timeout
    Here is a very useful little command that wait for a process to finish and kill it if doesn't exit after a pre defined timeout. The comm...
  • Microsoft Silverlight update repeatedly fails to install with error 0x80070643
    The Problem My wife made me aware that she always had one update to install while shutting down her computer. Being an IT guy by day, it too...

Categories

  • 007
  • 7
  • A+
  • Academic
  • Anti Virus
  • Antivirus Live
  • Avaya
  • AverPen
  • Bash
  • Begin
  • broken
  • Bugs
  • CentOS
  • CentOS 6.3
  • Centos 6.4
  • Certifications
  • CIP
  • ClamAV
  • Clean Slate
  • cli
  • CompTIA
  • Dead
  • Deal
  • Dell
  • Desktops
  • DHCP
  • Digital Camera
  • EBS
  • Error
  • Exchange 2007
  • fail
  • fax
  • File Systems
  • Firefox
  • Firewall
  • Fix
  • Flashback
  • FMTG
  • Fraud
  • FTP
  • GPO
  • Hard drive
  • Hardware
  • ICOP
  • IE8
  • Imaging
  • In-Car Video
  • Internet
  • Internet Explorer
  • IPO
  • ISA
  • Juniper
  • Kernel
  • Kodak
  • License
  • Linux
  • Microsoft
  • Microsoft Office
  • NERC
  • Network
  • Network+
  • Networking
  • NFS
  • Office 2010
  • OpenManage
  • Outlook2010
  • PDF
  • Performances
  • Phones
  • Ports
  • Presentation
  • printer
  • Protection
  • RAID
  • Remote
  • Renewal
  • Scam
  • SCE
  • Script
  • Security
  • Security+
  • Services
  • Shell
  • Shrew
  • Silverlight
  • SMS
  • SRX
  • SteadyState
  • Symantec
  • sysinternals
  • System
  • Tech
  • Text
  • Timer
  • Times Up
  • Tip
  • UAC
  • Unbootable
  • update
  • Virus
  • Virus Removal
  • VPN
  • Whiteboard
  • Windows
  • Windows 8
  • Windows Phone
  • Windows Server
  • Windows Update
  • Wireless
  • WSUS
  • Yahoo
  • Zabbix

Blog Archive

  • ▼  2013 (36)
    • ►  October (5)
    • ►  September (1)
    • ▼  August (1)
      • Bash : Wait for a command with timeout
    • ►  July (4)
    • ►  June (2)
    • ►  May (12)
    • ►  April (6)
    • ►  March (2)
    • ►  February (1)
    • ►  January (2)
  • ►  2012 (9)
    • ►  September (1)
    • ►  April (3)
    • ►  March (1)
    • ►  January (4)
  • ►  2011 (18)
    • ►  December (2)
    • ►  November (1)
    • ►  October (1)
    • ►  September (3)
    • ►  August (2)
    • ►  July (1)
    • ►  May (1)
    • ►  March (1)
    • ►  February (2)
    • ►  January (4)
  • ►  2010 (13)
    • ►  December (2)
    • ►  November (1)
    • ►  October (2)
    • ►  August (2)
    • ►  March (1)
    • ►  February (3)
    • ►  January (2)
  • ►  2009 (7)
    • ►  December (2)
    • ►  October (4)
    • ►  September (1)
Powered by Blogger.

About Me

Unknown
View my complete profile