TIMER ファイル形式とは?
.timerファイルは、ほとんどのLinuxディストリビューションで採用されている初期化システムおよびサービスマネージャーであるsystemdで使用されるタイマーユニットです。これは別のユニット(通常は対応する.serviceファイル)がいつ実行されるかをスケジュールし、cronの現代的な代替として機能します。ファイルはINI形式の小さなプレーンUTF-8テキストであり、プログラムコードではなくスケジュール情報を保持します。
各タイマーは通常、同じベース名を持つサービスとペアになります。例えば、backup.timerというファイルは、Unit=ディレクティブで別のターゲットが指定されていない限り、backup.serviceを起動します。ユニットは3つのセクションで構成されています。説明と依存関係を記述する[Unit]、スケジュールを記述する[Timer]、そしてWantedBy=timers.targetによる有効化を記述する[Install]です。
スケジュールには2つの形式があります。リアルタイムタイマーは、cronジョブのようにカレンダーイベントで実行するためにOnCalendar=を使用します。モノトニックタイマー(OnBootSec=やOnUnitActiveSec=など)は、起動や前回の実行といった基準イベントからの経過時間で実行されます。Persistent=trueなどのオプションを使用すると、マシンがオフだったために逃した実行を再開でき、RandomizedDelaySec=は多くのホスト間での負荷を分散させることができます。
セキュリティと安全性
リスク: LOWA .timer file is plain text with no executable code, so opening it in an editor is safe. The real consideration is trust: a timer can schedule any system command through its paired service, so only install units from sources you trust and review them before enabling with systemctl.
形式の詳細
概要- Construct 2/3 timer behavior data - Some game and animation tools store timer state, but this is not the dominant meaning of the extension.
- Generic application timer/config data - A few niche programs write settings files named with a .timer suffix; these are unrelated to systemd.
TIMER ファイルを開くプログラム
.timer file on a workstation before copying it to a Linux host; opens as plain text with optional systemd/INI highlighting. .timer unit as text before deploying it to a Linux server. vim /etc/systemd/system/name.timer; syntax highlighting for systemd units ships with Vim. nano /etc/systemd/system/name.timer; run systemctl daemon-reload afterward to apply changes. systemctl enable --now name.timer, inspect the schedule with systemctl list-timers, and check status with systemctl status name.timer. systemctl edit name.timer and validate its calendar expression using systemd-analyze calendar "OnCalendar-string". .timer file as a plain-text unit; the systemd/INI extensions add highlighting and directive hints. 技術的詳細
詳細仕様| Encoding | UTF-8 plain text |
| Byte order | Not applicable (text) |
| Container | None; INI-style key=value sections |
| Typical size | Under 1 KB |
| Structure | Three sections: [Unit] for description and dependencies, [Timer] for the schedule (OnCalendar, OnBootSec, OnActiveSec, OnUnitActiveSec, OnStartupSec, OnUnitInactiveSec, AccuracySec, RandomizedDelaySec, Persistent, Unit), and [Install] for enablement via WantedBy=timers.target. |
| Integrity | None built in |
| Platforms | Linux |
| Notes | Each .timer file normally pairs with a same-named .service file (foo.timer triggers foo.service unless Unit= overrides). Timers come in realtime (calendar) and monotonic (relative to boot, activation, or last run) forms and serve as a cron alternative managed through systemctl and logged to the systemd journal. |
| File Locations | System units in /usr/lib/systemd/system/ (packaged) and /etc/systemd/system/ (admin overrides); user units in ~/.config/systemd/user/ and /etc/systemd/user/. |
| Line Endings | Unix LF |
| リリース日 | 2012 (systemd timer units) |
| オープンスタンダード | はい · ロイヤリティフリー |
| 仕様書 | man7.org |
TIMER の変換
コミュニティ Q&A
ユーザーからの質問まだ質問はありません。TIMER ファイルについて最初の質問をしてみましょう。
よくある質問
.timerファイルはどうやって開きますか?
nano、vim、VS Code、Notepad++などのテキストエディタで開けます。小さなプレーンテキストファイルなので、読み取るために特別なソフトウェアは必要ありません。.timerと.serviceファイルの違いは何ですか?
.serviceファイルは「何を実行するか」を定義し、.timerファイルは「いつ実行するか」を定義します。backup.timerという名前のタイマーは、Unit=ディレクティブで別段の指定がない限り、backup.serviceを起動します。タイマーを有効にして開始するにはどうすればよいですか?
/etc/systemd/system/に配置し、systemctl daemon-reloadを実行してから、systemctl enable --now name.timerを実行します。systemctl list-timersで確認してください。systemdタイマーはcronよりも優れていますか?
Persistent=trueで逃した実行を補完できます。cronはよりシンプルで、Unixシステム間でのポータビリティが高いです。どちらも有効な手段ですが、現代のLinuxではタイマーが一般的です。タイマーが作動しないのはなぜですか?
systemctl status name.timerでタイマーが有効かつアクティブであることを確認し、対応するサービスが存在すること、およびOnCalendar=の式が正しいことを確認してください。systemd-analyze calendar "your-string"で式をテストできます。