Linux

Bash: How to Insert One White Space before and after English Words in Japanese

Submitted by admin on Wed, 09/28/2016 - 13:38

Consider to insert one white space before and after English word in Japanese. Run the following script by changing a string 'YOUR_FILENAME'. The script copy the original file as YOUR_FILENAME.org and overwrite and replace the original file by inserting one white space before and after an English word. It is useful multi-byte language such as CJK (Chinese, Japanese and Korean).
export FILENAME='index.rst'; \
cp ${FILENAME} ${FILENAME}.org; \
cat ${FILENAME}.org | sed y/0123456789/0123456789/ | \

Tags

DevOps: What You Should Know

Submitted by admin on Mon, 09/19/2016 - 14:00

1. Adjust the time amongst the server in your system
ntpdate time.apple.com

2. Check and monitor your disk space

Your service may stop after one year from the beginning of your service release date because the log files occupies a server disk space.
Use logrotate to truncate the log files (even if you are practicing that, the logs will overflow at the server).
Monitor the remaining disk space by using df command.

df -h

Docker: How to Change Image Name

Submitted by admin on Sat, 09/17/2016 - 15:54

Use a 'tag' command on docker.
docker tag <image_id> <repository_name>:<tag>

Note: You can omit the part '<tag>' and only write '<repository_name>'. The meaning of the <tag> string after colon (:) of the repository name is that you can put a different version image by changing the date or versions.
docker tag <image_id> <repository_name>

How to Run Linux cron Job at the End of Every Month

Submitted by admin on Thu, 09/15/2016 - 20:32

Edit /etc/crontab
vi /etc/crontab

Every end of the month
H 23 28-31 * * /usr/bin/test $( date -d '+1 day' +%d ) -eq 1 && <COMMAND>

Every last Friday of the month
0 0 * * 5 /usr/bin/test $( date +%m ) -ne $( date --date '7 day' +%m ) && <COMMAND>

These will be useful in Jenkins.
/usr/bin/test $( date -d '+1 day' +%d ) -eq 1

or
/usr/bin/test $( date +%m ) -ne $( date --date '7 day' +%m )

Tags

Bash: How to Show Escape Sequence Colors

Submitted by admin on Sun, 09/04/2016 - 14:49

Create the following script and run:
vi color.sh
chmod +x color.sh
./color.sh

The bash script:
#!/bin/bash

export txtrst='\x1b[00m' # Reset

echo
for i in {0..255} ; do
printf "\x1b[00;${i}m ${i}${txtrst}"
done
echo

echo
for i in {0..255} ; do
printf "\x1b[38;05;%03dm 38;05;%03d " ${i} ${i}
if [ $(( ${i} % 8 )) -eq 7 ] ; then
echo
fi
done
echo

Tags

Linux: How to Change the Timezone

Submitted by admin on Sat, 09/03/2016 - 14:45

To adjust timezone on your Linux to Pacific Standard Time (PST/PDT), type the following on command line.
sudo mv /etc/localtime /etc/localtime.org; sudo ln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime

To adjust timezone on your Linux to Japanese Standard Time (JST), type the following on command line.
sudo mv /etc/localtime /etc/localtime.org; sudo ln -s /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

Tags