I am wondering why my entire application runs in less than 8 seconds while the time obtained from clock_gettime is 19.3468 seconds which is more than two times as much as what happens in reality. Where is the problem from? Update: I am not using any OpenMP explicitly. Answer CLOCK_MONOTONIC should be used if …
Docker compose build error
If I use command docker-compose build, I’ll get error that looks like: I use the last version docker and docker-compose. My docker-compose.yml has the next code: I use an ubuntu 14.04 Could you tell me how is fix it? Answer You need to put the port definitions in quotes for short ports (2 digits). This …
Strange public key in authorized_keys
I’m using Linux VPS as a web server (haproxy+nginx+java+mysql+memcached+redis+solr), for security reason, I disabled password login and using key instead. These days, I can’t login to my server, when using VPS console to login, I found some strange public key in the /root/.ssh/authroized_keys, and…
Unzipping bz2 file
I have the following command to open a tbz file: The compressed file is about 15 GB and when it is expanded it is about 500GB or so. This operation on an ec2-4x-large operation takes roughly 1h40m. Is there a way to optimize this operation? What would be the fastest way to do the above operation? Answer A cou…
log text parsing in linux
I need to select a text from the log and store the field has a column to the new file. For example below is the log format Want to print the output like below i have used awk to print as column wise How to get the value using like, the id as key and inside the double quotes is
Preserve timestamp when editing file
I want to preserve the timestamp of the files I’m editing in a for loop The issue is I need to get a formatted date string from the file so that I can do touch -r to revert the files date back once the loop has completed. stat is not giving the me the format I need. Required Format: YYMMDDhhmm
How can i execute comm Linux command in Python
I want to extract lines from File1 which are not present in File2 File1 File2 so the output should be: One possible command in bash is: And it works perfectly well in bash, but I don’t know how correctly to implement in Python. I’ve tried with And is not working. Any hint? Answer If you must use a…
C segmentation fault on linux with strncmp
This works (‘Y’ must be single quotes): This gives segmentation fault: strncmp must be going off the deep end but not sure why since I’m passing a casted toupper() as (char *). Without the casting, same error. FYI user_input() is (N.B. vars are global): Thank you. Answer The return value of …
Curses snake game not removing cells in linux os
It’s code from a curses tutorial that I’ve been using to get a grasp of it but even though I’ve checked the code multiple times, it’s still not removing the old cells. The guy that wrote the code is on a mac and I’m using linux so would that be a problem? Answer The problem seems…
Use of MONO_IOMAP to cope with a hard-coded file path?
I’m trying to get a Windows .NET binary to run under Linux using Mono. The app runs fine on Windows. It presently fails under Mono because it can’t find a file with a hard-coded path. For testing, I’m using a Fedora 23 VirtualBox VM running under Windows 7. All the files are present on the V…