2022年1月20日星期四

shell command readlink

$ readlink  -f ./script/test.sh
/home/user/script/test.sh

#check file or directory exists.
readlink -v $dir/env
readlink: ./script/env: No such file or directory

#no check file or directory exists.
$ readlink -m $dir/env
/home/eru/im-convoy-master/script/env

$ readlink --help
Usage: readlink [OPTION]... FILE...
Print value of a symbolic link or canonical file name
  -f, --canonicalize            canonicalize by following every symlink in
                                every component of the given name recursively;
                                all but the last component must exist
  -e, --canonicalize-existing   canonicalize by following every symlink in
                                every component of the given name recursively,
                                all components must exist
  -m, --canonicalize-missing    canonicalize by following every symlink in
                                every component of the given name recursively,
                                without requirements on components existence
  -n, --no-newline              do not output the trailing delimiter
  -q, --quiet,
  -s, --silent                  suppress most error messages (on by default)
  -v, --verbose                 report error messages
  -z, --zero                    end each output line with NUL, not newline
      --help     display this help and exit
      --version  output version information and exit


2022年1月17日星期一

Linux auto start system by cron

$ ls -l /etc/crontab
-rw-r--r-- 1 root root 701 Jan 11 11:04 /etc/crontab

$ cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed
 30   *  *  *  * ec2-user /home/user/cicd.sh

# Directories of different times.
/etc/cron.d/     #all kind files
/etc/cron.hourly/   
/etc/cron.daily/       
/etc/cron.weekly/
/etc/cron.monthly/

#user list of allow or deny.
/etc/cron.allow
/etc/cron.deny

#check at service
$ systemctl status atd
● atd.service - Job spooling tools
   Loaded: loaded (/usr/lib/systemd/system/atd.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2022-01-17 09:01:43 JST; 55min ago
 Main PID: 4523 (atd)
    Tasks: 1
   Memory: 484.0K
   CGroup: /system.slice/atd.service
           mq4523 /usr/sbin/atd -f

Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

#run atd if not started.
$ systemctl start atd

#auto started with os.
$ systemctl enable atd

#Example: run backup.sh at 2016/10/17 19:15 
$ at "19:15 17.10.16"  -f backup.sh                           
at 10pm -f backup.sh      #run backup.sh at 22:00           
$ at now + 4days backup.sh  #run at the same time after 4days.
$ at 9pm + 3weeks           #run at 21:00 after 3weeks        




2022年1月11日星期二

Oracle SJIS UTF bytes

1.キャラクターセット

Oracle Databaseで取り扱う文字コードは、データベース作成時に設定するデータベースキャラクターセット(CHARACTER SET)、各国語キャラクターセット(NATIONAL CHARACTER SET)で決定されます。

※作成後、変更が出来ないので十分検討が必要です。

2.データサイズの違い

 JA16SJIS(TILDE)AL32UTF8
半角英数1バイト1バイト
半角カナ1バイト3バイト
全角文字2バイト3バイト
補助文字2バイト4バイト