presents by IT Consulting 109

サンプルファイルの作成(Linux編)

概要


Linuxでのサンプルファイルの作成手順について記載しています。

ログのローテーション管理の検証などで役に立ちます。

 

手順


次のコマンドを実行します。
※例として10月のログファイルを一括で作成

touch rotation_test_file_{1001..1031}

作成日時がコマンド実行時になってしまうのでタイムスタンプを修正

touch -d "2017/10/01 00:00:00" rotation_test_file_1001
touch -d "2017/10/02 00:00:00" rotation_test_file_1002
touch -d "2017/10/03 00:00:00" rotation_test_file_1003
touch -d "2017/10/04 00:00:00" rotation_test_file_1004
touch -d "2017/10/05 00:00:00" rotation_test_file_1005
touch -d "2017/10/06 00:00:00" rotation_test_file_1006
touch -d "2017/10/07 00:00:00" rotation_test_file_1007
touch -d "2017/10/08 00:00:00" rotation_test_file_1008
touch -d "2017/10/09 00:00:00" rotation_test_file_1009
touch -d "2017/10/10 00:00:00" rotation_test_file_1010
touch -d "2017/10/11 00:00:00" rotation_test_file_1011
touch -d "2017/10/12 00:00:00" rotation_test_file_1012
touch -d "2017/10/13 00:00:00" rotation_test_file_1013
touch -d "2017/10/14 00:00:00" rotation_test_file_1014
touch -d "2017/10/15 00:00:00" rotation_test_file_1015
touch -d "2017/10/16 00:00:00" rotation_test_file_1016
touch -d "2017/10/17 00:00:00" rotation_test_file_1017
touch -d "2017/10/18 00:00:00" rotation_test_file_1018
touch -d "2017/10/19 00:00:00" rotation_test_file_1019
touch -d "2017/10/20 00:00:00" rotation_test_file_1020
touch -d "2017/10/21 00:00:00" rotation_test_file_1021
touch -d "2017/10/22 00:00:00" rotation_test_file_1022
touch -d "2017/10/23 00:00:00" rotation_test_file_1023
touch -d "2017/10/24 00:00:00" rotation_test_file_1024
touch -d "2017/10/25 00:00:00" rotation_test_file_1025
touch -d "2017/10/26 00:00:00" rotation_test_file_1026
touch -d "2017/10/27 00:00:00" rotation_test_file_1027
touch -d "2017/10/28 00:00:00" rotation_test_file_1028
touch -d "2017/10/29 00:00:00" rotation_test_file_1029
touch -d "2017/10/30 00:00:00" rotation_test_file_1030
touch -d "2017/10/31 00:00:00" rotation_test_file_1031

作成しながらタイムスタンプの設定ができればよいのですが現在調査中…

この記事を書いた人
名前:TRUE's。 千葉県育ち、神奈川県在住のIT系フリーエンジニア。 IT系のナレッジサイトを不定期で更新中。 フォトグラファー兼エンジニアとして日々勤しんでいる。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です