LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-07-2018, 02:05 PM   #1
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,530

Rep: Reputation: 311Reputation: 311Reputation: 311Reputation: 311
BASH - handle running a command which doesn't return


I've written a short BASH script - which runs as a CRON job (under user authorities).
This runs every two hours.

It runs a command, speedtest-cli which returns a text string which I reformat & write to a CSV log file.
This allows me to occasionally use GNUPLOT to display the transfer rate I get from my ISP as a graph.

The problem is that speedtest-cli accesses a semi-random web site (from an inbuilt list) and sometimes it "dies" and doesn't return anything which results in inactive jobs just sitting around.

Ideally, I'd like to be able to kill the thing cleanly if it doesn't finish in about a minute or so?

Does BASH have any constructs that allow jobs to kill themselves?
 
Old 03-07-2018, 02:48 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,803
Blog Entries: 15

Rep: Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652
Have a look at the "timeout" command.

http://man7.org/linux/man-pages/man1/timeout.1.html

It is part of coreutils package.
 
1 members found this post helpful.
Old 03-07-2018, 05:38 PM   #3
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,530

Original Poster
Rep: Reputation: 311Reputation: 311Reputation: 311Reputation: 311
Thank you - Solved!
 
2 members found this post helpful.
Old 03-08-2018, 07:20 AM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,803
Blog Entries: 15

Rep: Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652
Glad I could help. If you don't mind, please go to thread tools and mark this as Solved. It helps future web searchers more quickly find solutions.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash, return value and $? from a command call a4z Programming 11 05-29-2014 01:59 PM
[SOLVED] [bash]sort command - how to handle a tie condition schneidz Programming 4 04-03-2011 04:56 AM
Redirect doesn't return stderr of child to parent command errorfile demxkn66 Programming 7 11-30-2007 05:59 AM
Bash command/script to return group of file IHateFriction Programming 3 03-09-2007 12:31 PM
nohup command in script doesn't return to system console prompt beammeup Linux - Software 4 02-05-2007 02:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration