Why does `ping` not timeout in Linux? [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I just figured out, that ping on a Linux platform (Ubuntu 13.10) does not timeout as described. I tried
ping -w 2 unreachable.com
and
ping -W 2 unreachable.com
but in neither case there was a timeout after 2 seconds. How can I use ping with a definite timeout? Is that possible at all? I want the command to stop after 2 seconds, regardless of any connection status.

ping -c 5 -W 2 will send out 5 pings, waiting 2 seconds max for each of them (a total max of 10 seconds).
ping -w 5 will send out pings, but will stop after 5 seconds.
You have to be careful with name resolution: if you use a name instead of an IP address, the resolution of the name does not count into these timeouts & waits (pinging and time measurements start only after the name resolution has finished). If you use DNS, you can set DNS timeouts in /etc/resolv.conf - see its man page.

Are you misinterpreting the flag? If I understand correctly:
The -W flag will specify how long to wait for a reply. By setting -W 2, according to the man page:
Time to wait for a response, in seconds. The option affects only timeout in absense of any responses, otherwise ping waits for two RTTs
So running it like you have and waiting for 2 seconds doesn't actually let you know if it has given up waiting for the response or not.

Related

How can I customise the shutdown command in linux so that an user is not able to shutdown before 2 hours and also not delay beyond 999 mins [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 days ago.
Improve this question
In other words I have to set the upper and lower limit of time for shutdown command in linux.
I tried to write a wrapper or a .sh file which will get call once a user executes shutdown command but am not sure how the call to .sh works.

last | reboot in linux rebooted the machine, can someone explain why ? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
how does the pipeline work in the below?
last | reboot
The above rebooted the linux machine.
last search the last logged in user and last output is given to reboot and reboot will reboot the system.
last | reboot
| | => process1 output will be input
process1 process2 for process2
See the man 1 last it says
Last searches back through the file /var/log/wtmp (or the file
desig‐
nated by the -f flag) and displays a list of all users logged in (and
out) since that file was created.
As Daniel says importantly, reboot doesn't care about its input. It probably doesn't read it at all, so piping something in doesn't change its behavior.

How to stop a c++ code from running [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I clicked on a.out of a code in Linux, now I want to stop running code but as I didn't use the terminal, I don't know that how can I stop the code from running. What can I do?
I am running another code from last week.
I can not kill both by turn off the computer because the first code is running from previous week and I don't have time to run it again
So, if you're running two instances of a.out (which I'm just assuming because your question is unclear...) then, as other users have said, run:
pgrep a.out
If the second a.out process is the one you want to kill, take the larger PID number (in your case it seems to be 19564) and run:
kill 19564

/dev/ttyACM busy for the first 15 seconds after plugging [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I have two USB devices which appear as /dev/ttyACMn (a barcode reader and a motor controller). For each of them, when I try to open them in the first 15 seconds after plugging in, I get a "device or resource busy" error. After more than 15 seconds, they open fine. Do you have any idea what's causing it?
I tried using lsof to check if a process is using the device, but it finds no such process (it finds my process after I manage to connect to the device).
I'm currently using Ubuntu 14.04, kernel 3.13.0 64-bit, but I have seen this behavior in earlier Ubuntu versions too.
Thank you very much,
Noam
I think the problem is ModemManager. It scans serial interfaces on startup to see, if they belong to a modem.

Limit packets per minute per IP address [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Only using IPTABLES, how would you limit requests (pings for example) from the same Internet host to x number of packets per minute, say 5 for simplicity sake?
iptables -A INPUT -p ICMP -m limit --limit 5/minute --limit-burst 5 -j ACCEPT
-m limit: This uses the limit iptables extension
–limit 5/minute: This limits only maximum of 5 connection per minute. Change this value based on your specific requirement
–limit-burst 5: This value indicates that the limit/minute will be enforced only after the total number of connection have reached the limit-burst level.
The above should do the trick!

Resources