Where is MySQL / MariaDB storage location by default on CentOS 7? No special configuration to the MariaDB from official repository of CentOS. On CentOS 7 Linux it is usually by default /var/lib/mysql But here I give you another “hacky” way to find it out. The method is to find out the mysql daemon mysqld’
Read more
Tag: Process
How to pause and resume the execution of a process on Linux?
Posted onHow to pause the execution of a process on Linux so that the CPU can be freed? Later, if the node is idle again, how to resume the execution? There are 2 signals related to stopping (pausing) and continuing (resuming) processes: Stop Default action is to stop the process. Cont Default action is to continue
Read more
How to detect whether a file is being written by any other process in Linux?
Posted onHow to detect whether a file is being written by any other process in Linux? Before a program open a file to processes it, it wants to ensure no other processes are writing to it. Here, we are sure after the files are written and closed, they will not be written any more. Hence, one-time
Read more
Killing Running Bash Script Process Itself and All Child Processes In Linux
Posted onIn Linux, how to kill a process and all its child processes? For example, a Bash script A starts B, B starts C and C calls rsync. I would like to kill A and all its child processes all together. How to do this? There are possibly many answers to this question. One of the
Read more
How to get the running process’ parent process’ ID in Python?
Posted onHow to get the running process’ parent process’ ID in Python? In Python, you can get the parent process’ pid by calling os.getppid(): import os ppid = os.getppid() One example: The shell’s pid: $ echo $$ 21779 Start a python REPL and get its parent pid (the shell’s): $ python Python 2.7.5 (default, Nov 6
Read more
How to get the running process’ parent process’ ID in Go?
Posted onHow to get the running process’ parent process’ ID in Go? In Go, you may call the os.Getppid() func from the os package to get the parent process’ pid. func Getppid() int Getppid returns the process id of the caller’s parent. One example is as follows. $ gore gore version 0.2.6 :help for help gore>
Read more
How to get the running process’ parent process’ ID in C / C++?
Posted onHow to get the running process’ parent process’ ID in C / C++? In C and C++, you can call the getppid() library function which is a function from the POSIX library. #include <sys/types.h> #include <unistd.h> pid_t getppid(void); getppid() returns the process ID of the parent of the calling process. Example usage: getppid.c #include <stdio.h>
Read more
How to get the running process’ pid in Go?
Posted onHow to get the running process’ pid in Go lang? In Go, you may call the os.Getpid() func from the os package to get the parent process’ pid. func Getpid() int Getppid returns the process id of the caller. One example is as follows. $ gore gore version 0.2.6 :help for help gore> :import “fmt”
Read more
Getting Process Own Pid in C and C++
Posted onHow to get the running process’ pid in C / C++? In C and C++, you can call the getpid() library function which is a function from the POSIX library. #include <sys/types.h> #include <unistd.h> pid_t getpid(void); getppid() returns the process ID of the calling process. An example C program to get self process ID getpid.c:
Read more
How to get the running process’ parent process’ ID in Bash?
Posted onHow to get the running process’ parent process’ ID in Bash? In Bash, you can get the parent process’s pid from the variable PPID. Note that in a (…) subshell, the $$ stores the subshell’s parent shell pid actually.
How to get the running process’ pid in Bash?
Posted onHow to get the running process’ pid in Bash? In Bash, you can get the process ID from the variable $$. Note that in a subshell invoked by ‘(…)‘, $$ is actually the parent process’ pid. In Bash 4, you can also use $BASHPID to get the process pid.
Getting the running process’ own pid in Python
Posted onHow to get the running process’ pid in Python? In Python, you can get the pid of the current process by import os os.getpid() From the official doc: os.getpid() Return the current process id. One example os using os.getpid() to get process own ID: $ python3 Python 3.8.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0]
Read more
How to process a file line by line in Bash?
Posted onIn Bash, how to process a file line by line? The file is a plain text line like input.txt. As an example, the process can be to just print it out. In Bash to process a file ./input.txt line by line: while read line ; do echo $line done < ./input.txt Reference: https://www.systutorials.com/qa/2166/how-to-process-a-file-line-by-line-in-go
How to process a file line by line in PHP?
Posted onIn PHP, how to process a file line by line? The file is a plain text line like input.txt. As an example, the process can be to just print it out. In PHP, you can use this code snippet to process a file line by line: if ( ($fhandle = fopen(“./input.txt”, “r”) !== FALSE )
Read more
Reading and Processing a File Line by Line in C++
Posted onIn C++, how to process a file line by line? The file is a plain text line like input.txt. As an example, the process can be to just print it out. In C++, you may open a input stream on the file and use the std::getline() function from the <string> to read content line by
Read more
How to process a file line by line in Python?
Posted onIn Python, how to process read a file line by line to process it? Like those lines in Bash: while read line ; do echo $line done < ./input.txt In Python, you can process a file line by line by a for in the file like with open(“./input.txt”, “r”) as thefile: for line in thefile:
Read more
How to set process with lowest priority?
Posted onIn system, sometimes, we need backstage threads with very very low priority since it cannot preempt any normal process asks for CPU. SCHED_IDLE class satisfies this requirement which has the priority lower than “nice=19” of CFS. Following code does this. 241 void set_idle_priority(void) { 242 struct sched_param param; 243 param.sched_priority = 0; 244 int s
Read more
What is the vruntime of one process after it is moved into another run queue in Linux Kernel
Posted onWhen we do migration, one process will be migrated from one source CPU’s runqueue to destination CPU’s run queue. What is the virtual run time (if CFS is used) after it is moved into destination CPU’s run queue? When the process is dequeued from source CPU’s run queue, its vruntime will minus the minimum vruntime
Read more
How to output function stack in Linux Kernel
Posted onIn Linux Kernel, we usually trace/debug what kind of events will trigger the phenomena we find in the system. For example, what kind of event will trigger the fact that the timeslice of one process will be very short. In order to solve these kind of problems, we need to output the function stack. Currently,
Read more
How to make tee catch the stderr only in Linux?
Posted onI would like to make tee catch the stderr and log it into a file. A brute force method by let tee listen on both stderr and stdout is okay like cmd 2>&1 | tee -a log But how to make tee catch the stderr only? You can make use of “process substitution” (>(…)) to
Read more