Create a job using crontab

To automate tasks or create some monitoring job we can use the older and efficient tool the β€œCronJob”. For our example, I’ve created a simple script to detect the cache memory and clean it if raise to a condition then send a notification by mail. Library used: exim4 (mail server) or ssmtp (mail server). Both uses the same β€œmail” command. Script: # grab the buff/cache memory mem="$(free -m | grep 'Mem:' | awk '{print $6}')" if (( $mem > 350 )) then echo 'wooo is more than 250M' echo 3 | sudo tee /proc/sys/vm/drop_caches echo 'cache dropped' echo "Memory buff/cache cleaned last value:" $mem | mail -s "cache_memory" target_mail@local....

2019-04-03

Parsing date format from .xlsx to R

Version: platform x86_64-redhat-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu version.string R version 3.5.3 (2019-03-11) Library lubridate Parse method β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” as.factor β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” mydata$FECHA_NACIMIENTO<-as.factor(mydata$FECHA_NACIMIENTO) β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” variable for strptime β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” tempo<-strptime(mydata$FECHA_NACIMIENTO,"%d/%m/%Y") mydata$FECHA_NACIMIENTO<-as.Date(tempo,"%d/%m/%Y") β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” clean variable β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” rm (tempo) mydata$FECHA_NACIMIENTO <- format(as.Date(mydata$FECHA_NACIMIENTO), "%d/%m/%Y") β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” parsing data β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” library(lubridate) mydata$FECHA_NACIMIENTO <-dmy(mydata$FECHA_NACIMIENTO)

2019-04-01

Disable live-restore to run Docker Swarm

The following instruction is a solution when you got an error response with live-restore using Docker Swarm in Fedora 28 or highter $ docker swarm init Error response from daemon: --live-restore daemon configuration is incompatible with swarm mode That’s not possible to enable Live-restore and Swarm-mode together. First make sure that the SElinux is Permissive or Disabled. $ sestatus SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: permissive Mode from config file: enforcing Policy MLS status: enabled Policy deny_unknown status: allowed Memory protection checking: actual (secure) Max kernel policy version: 31 Then remove the –live-restore line from the /etc/sysconfig/docker...

2019-03-28

Pulling Mysql using Docker Hub into Linux workstation

$ systemctl start docker $ systemctl status docker $ docker pull mysql $ docker image ls $ docker run --name db -e MYSQL_ROOT_PASSWORD=mysql123 -d mysql Use the docker exec -it command to start a mysql client inside the Docker container you have started, like the following: $ docker exec -it db mysql -uroot -p

2019-03-28

Enable "Kubectl" auto-completion in the Shell (Linux)

When you’ve done the SDK installation in your Linux workstation. list the components you have installed, then you will see the full list additional components from gcp SDK: gcloud components list gcloud components install <COMPONENT_ID> gcloud components install kubectl Then follow the instruction from the kubernetes official documentation, check the β€œbash-completion” and finally issue the command below: echo "source <(kubectl completion bash)" >> ~/.bashrc Even you can go directly through your ....

2018-11-25