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
Tag: bash
terminate a job after few seconds and process to next step in loop
Short question Terminate a downloading command after few seconds Long detailed I have a file in which every line has a cron job written in such a way that if i parse over it line by line, then i will be able to run it manually. somewhat like this i want to cross check if i’m able to run all
Qt application autorun on linux embedded – “xcb” error
I develop software in Qt for a microcomputer based on Cortex imx6. On this platform, I have installed Linux prepared for this uP and Qt. uname -a Linux colibri-imx6 4.1.35-v2.7b1+gc1177831f5a1 #11 SMP Tue Jun 20 13:05:01 CEST 2017 armv7l armv7l armv7l GNU/Linux I want to run my app during system startup and I…
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:
How to kill a process after a given real running time in Bash?
For killing a process after a given timeout in Bash, there is a nice command called timeout. However, I’m running my program on a multi-user server, and I don’t want the performance of my program to be influenced by others. Is there a way to kill a process in Bash, after a given time that the prog…
Colorizing echo works in Solaris but doesn’t work in Linux
I have 2 different servers where I log in with same network user and run the same script. One is Solaris and another is Linux. Sample echo line from the script works differently on those servers: In Solaris -> it displays the text “auto update” correctly in green In Linux -> it displays the …