Items tagged with: codeanalyse
Article: How to Use the
timeout Command on Linux.
by David McKay (Twitter: @TheGurkha), hosted by How-To Geek.
Preview of the article
timeoutcommand allows you to set a limit on the length of time a program will run for. But why would you want to do that? [...]
timeoutis part of the GNU Core Utils so Linux and Unix-like operating systems such as macOS all have timeout built right in. There’s nothing to install; you can use it right out of the box.
One case is when you know exactly how long you want a process to run for. [...] Another case is when you don’t know how long you want a process to run for, but you do know you don’t want it to run indefinitely. [...] Some data capture files can grow big very quickly. To prevent such files becoming unwieldy or even problematic in size, limit the amount of time the capture program is allowed to run. [...] Examples ...
For some reason, it is very easy to forget that this command exists. We should use it more often, as it can save us the need to create a new systemd service only to set a timeout.
Tags: #linux #bash #gnu #coreutils #software #script #os #scripting #coding #codeanalyse #networking #development
Article: Network Redirections in Bash.
by Anmol Sarma - software developer from Bengaluru ( #India ).
[...] it sends a UDP datagram containing a random number to port 1234 every 250 ms.
while true; do echo $RANDOM > /dev/udp/127.0.0.1/1234; sleep 0.25; done
I didn’t recall ever seeing a
/dev/udpand so was a bit surprised that it worked.
Seemingly, a normal UDP socket was being created and written to using the regular sycall interface. That refuted my initial suspicion that some kind of a special file backed by the kernel was involved.
But who was actually creating the socket?
A peek at Bash’s code answered that question [...]
Tags: #linux #bash #ksh #scripting #script #networking #hacking #coding #code #codeanalyse #development #syscall #udp #tcp.