Some of my pages has XML tags like ‘<?xml ?>’ which are considered by PHP as short open tags ‘<? ?>’. How to disable PHP short open tags? In PHP, to disable the short open tags, you can set the variable short_open_tags = FALSE; in your php.ini. Reference: short_open_tags in php.ini Answered by Eric Z […]
How to find out all files with replication factor 1 in HDFS? The hdfs dfsadmin -report shows there are blocks with replication factor 1: Missing blocks (with replication factor 1): 7 How to find them out? You can run hdfs fsck to list all files with their replication counts and grep those with replication factor […]
How to add a prefix string at the beginning of each line in Bash shell script on Linux? For example, assume we have a file a.txt: line 1 line 2 I want to have, pre line 1 pre line 2 You may use sed, the stream editor for filtering and transforming text: sed -e ‘s/^/pre […]
How 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 […]
How to make CentOS Linux to load a module, say ixgbe, automatically at boot time? I am using CentOS 7. You can create a text file <some name>.conf in the /etc/modules-load.d/ and list the modules to be loaded there, one per line. The systemd-modules-load.service daemon will read these files and load the modules. Check more […]
It is useful to monitor a server node’s temporary. Among all the sensors’ temperatures, the higher one may be a very important one. How to get the highest temperature from all sensors in a server on Linux? You can use this command to get the the highest temperature from all sensors in a server on […]
WPS’ wpp program reports “libbz2.so.1.0: cannot open shared object file” on CentOS 7 as follows: $ wpp /opt/kingsoft/wps-office/office6/wpp: error while loading shared libraries: libbz2.so.1.0: cannot open shared object file: No such file or directory The reason: wpp will tries to dynamically link ‘libbz2.so.1.0’ $ ldd /opt/kingsoft/wps-office/office6/wpp | grep libbz2 libbz2.so.1.0 => not found libbz2.so.1 => […]
I have a very large (e.g. 100GB) .gz file and would like to split it into smaller files like 8GB/each for storage/copying. How to split a gzip file to several small ones on Linux? You may use the tool split to split a file by sizes. An example to split a large.tgz to at most […]
How to get the mtime of a file on Linux from the file’s path? You can use stat to get the file status including the mtime: %y time of last modification, human-readable %Y time of last modification, seconds since Epoch As an example, $ stat -c %y ./file 2017-06-26 13:33:06.764042064 +0800 $ stat -c %Y […]
How 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 […]
How 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> […]
How 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. Example usage: getpid.c #include <stdio.h> #include <sys/types.h> #include <unistd.h> int […]
How 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. Answered by dtivl.
How 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” […]
How to debug a Bash script if it has some bugs? Common techniques like printing varibles out for checking apply for bash too. For bash, I usually use 2 bash-specific techniques. Add set -o errexit to the beginning of the scripterrexit makes bash exit immediately if one statement’s return code is not 0. This way, […]
How 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. Answered by dtivl.
How 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. Answered by dtivl.
In Zimbra server, how to set Zimbra web service’s hostname and port? Set Zimbra Web service’s host and port (to mail.domain.com:80 as an example) for a mail domain domain.com: zmprov md domain.com zimbraPublicServiceHostname mail.domain.com zmprov md domain.com zimbraPublicServicePort 80 Reference: https://wiki.zimbra.com/wiki/When_using_a_proxy,_the_’change_password’_box_doesn’t_load Answered by Eric Z Ma.
How to get the version of Zimbra I am using in a Zimbra server? In Zimbra, to get the version of Zimbra you are using, you can call zmcontrol -v: $ zmcontrol -v Release 7.2.6_GA_2926.F13_64_20131203115902 F13_64 FOSS edition. Answered by Eric Z Ma.
In C, ow to get the hostname of the node? In C, you may use the gethostname function. #include <unistd.h> int gethostname(char *name, size_t namelen); The gethostname() function shall return the standard host name for the current machine. The namelen argument shall specify the size of the array pointed to by the name argument. The […]