Home Check if timeout command was successful
Reply: 0

Check if timeout command was successful

user590
1#
user590 Published in May 27, 2018, 3:32 am

I am trying to run a command in a bash file and put the output of command in a variable. But the command must NOT take longer than 2 seconds. I use the command:

timeout -k 2 2 ls /var/log/;

And there is no problem. The command either list the contents of log directory or kills the command in case it took more than two seconds. But when I try to put the output in a variable the commands hangs and doesn't reply or get killed! I use like this:

result=$(timeout -k 2 2 ls /var/log/);

Where is my mistake?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.404498 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO