I am facing a issue related to Docker users. I run my container as gitlab-runner using the following command: The files created inside the docker container show owner gitlab-runner, however, the same files show in my host machine as owner roggerfernandes. gitlab-runner must be the owner of files created insid…
Tag: linux
linux c++ libev official example show redundant console behavior
I just tried the official example of libev, like below. After compiling and running, I see once I input anything from stdin, the event is triggered, no problem. But what I inputed is still treated as solid input and then appear on my console. My question is: is there a way to avoid this console input from bei…
Using linux epoll: epoll_ctl seems to have redundant parameter?
Usually on linux when we wish to use epoll, we first create a epfd, and then register fd and events to it. Above is a common example I found from internet. It works, but problem is: ev.data.fd=fd here I already have my “fd” assigned to ev structure. epoll_ctl still requires the 3rd parameter of th…
The Linux timeout command and exit codes
In a Linux shell script I would like to use the timeout command to end another command if some time limit is reached. In general: But I also want that my shell script exits when the command is failing for some reason. If the command is failing early enough, the time limit will not be reached, and timeout will…
a program to alert when /var files system usage reaches threshold
I am working on a program which will send an snmp alert when /var reaches maximum threshold. I am having trouble with calculating % of /var disk usage for this. I have this command “du -hs /var” which give me usage of /var in MB and /var is in the /root directory. So to calculate total disk on whi…
Exit whole script from code block { }
I have the following script: But the problem is that the {} block is exiting and not the whole script. How can I make the whole script exit? Answer Add the following line after your tee command: test ${PIPESTATUS[0]} -eq 0 || exit ${PIPESTATUS[0]} Reference Link: https://stackoverflow.com/a/34386000/2357256
cpp multipleThread: detach non-class type error
I’m writing a program with mutiplethread using cpp , but I have a compiler-error like this: my code could be presented as follow: So anybody have a clue about where I did wrong and what can I do? Answer You’ve hit C++’s Most Vexing Parse. The above declaration doesn’t declare a turnCam…
Father-child process use pipe to talk, hangs after “execlp”, why?
I’ve got a simple text file called “tmp” under current directory, I wish to “cat” this file and then “sort” it, I want to use a c program to act like pipe “|” so I tried to use a father/child talk to do this. Unexpectedly, the program hangs after “ca…
GDB doesn’t recognize some C functions
So I’m new to Linux and just got Ubuntu 16.04.2 running on a VM. I’ve installed gcc/g++ on here in the terminal, but when I run my program in GDB, as soon as I get to a strcmp function, this pops up for many lines. And when I go further down: So I’m guessing it just doesn’t recognize m…
How do I classify files in Linux server by their names?
How can use the ls command and options to list the repetitious filenames that are in different directories? Answer You can’t use a single, basic ls command to do this. You’d have to use a combination of other POSIX/Unix/GNU utilities. For example, to find the duplicate filenames first: This means …