Skip to content

Tag: bash

Why does flock removes existing text from a file?

So, I am trying to get an exclusive lock on a text file using Flock and a line of text to that file however while doing so it removes whatever text was there earlier. So if the file had let’s say and after running the script I am expecting something like instead, all I get is why would it behave

How to simplify the comparison in the bash?

how to make several comparisons in the bash by placing the condition and comparison points next to instead of the long queue ? that something like this before : after (what I want): Answer Try this using bash regex with the keywork =~: Edit : As seen in comments, for real you need to compare int, not strings,…

How to use environment variables in a .service script

I have an elixir project on a linux server. I have created a .service script which will start and stop the application with the following commands The .service file looks something like this… It works as expected, the one exception being that it will not read the environment variables. I can give the ap…

Grep Regex: How to find multiple area codes in phone number?

I have a file: each line consist of a name, room number, house address, phone number. I want to search for the lines that have the area codes of either 404 or 202. I did “(404)|(202)” but it also gives me lines that had the numbers in the phone number in general instead of from area code, example:…

Multi Hop, Self Closing, Background SSH Tunnel

I’m trying to create a multi hop ssh tunnel, that is in the background, and self closing. What I have is… This successfully creates a multi hop ssh tunnel that closes the port on host1 after I close the tunnel. However, if I try to fork it to the background, like this… It runs in the backgro…

No activity on server with logging every 5 seconds

Recently I have notices that log files on my server grow faster than I was expecting. After a quick look I have realized that it is wtmp what aggressively is taking my disk space. Using utmpdump command (see below) I found out that every 5 seconds new 3 or 4 logs are recorded. There is no load on the server: