[HOW TO] get up time process linux?

Once day you want to get the up time of application/ process. But you cannot really tell how long the process has been alive. To get this you may use a couple of commands like the following:

cattek@cattek:~$ ps -ax | grep nylas
 7290 ?        Sl     0:22 /usr/share/nylas/nylas
 7294 ?        S      0:00 /usr/share/nylas/nylas --type=zygote --no-sandbox
 7320 ?        Sl     0:00 /usr/share/nylas/nylas --type=gpu-process --channel=7290.0.1818467183 --mojo-application-channel-token=EA75EFF296429385F4F336F81485903C --no-sandbox --window-depth=24 --x11-visual-id=32 --supports-dual-gpus=false --gpu-driver-bug-workarounds=5,18,48,56 --disable-gl-extensions=GL_ARB_occlusion_query GL_ARB_occlusion_query2 --gpu-vendor-id=0x8086 --gpu-device-id=0x191e --gpu-driver-vendor --gpu-driver-version --gpu-driver-date --v8-natives-passed-by-fd --v8-snapshot-passed-by-fd

The first column contains the PID, In this case, 7320 is the PID of the master process

cattek@cattek:~$ ps -p 7320 -o etime=
   01:26:58

Nice, good luck for you. Finally you can now write a script.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

[HOW TO] fix Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

When I reset 'mysql' root password, I couldn't do it. MySQL shows the notification:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' 

Firstly I kill all mysqld's process with
$sudo killall -9 mysql

But nothing to show.

Wait wait, I see /var/run/mysqld/mysqld.sock, but I couldn't found this.

Finally I found the solution:
$sudo /etc/init.d/mysql stop
$sudo mkdir /var/run/mysqld/
$sudo chown mysql /var/run/mysqld/
$sudo mysqld_safe --skip-grant-tables &
mysql -uroot
>use mysql;
>update user set authentication_string=PASSWORD("NEW_PASSWORD") where User='root';
>flush privileges;
>quit;
>sudo /etc/init.d/mysql stop
>sudo /etc/init.d/mysql start

However you also can do this to update mysqld's password.
>ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
>flush privileges;
>quit;

Hope this help,

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success