1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【cron】crontabのエディタを変更する方法

Posted at

設定方法

crontab のエディタはEDITOR変数で変更できます。
~/.zshrcに以下のように記述すると vim に変更されます。

~/.zshrc
export EDITOR=vim

しかしVSCodeに変更する際に以下のように記述するとVSCodeは開きますが、編集前にcrontab -eコマンドが終了してしまうためcorntabの編集ができません。

~/.zshrc
export EDITOR=code
ターミナル
$ crontab -e
crontab: no changes made to crontab

編集前にcorntab -eコマンドが終了してしまうのを回避するために以下のようにします。

まず以下の内容でcode-wait.shを作成します。

code-wait.sh
#!/bin/zsh
code --wait "$@"

次にcode-wait.shに実行権限を与えます。

ターミナル
sudo chmod +x /path/to/code-wait.sh

または

ターミナル
sudo chmod 755 /path/to/code-wait.sh

そして~/.zshrcに以下を追記します。

~/.zshrc
export EDITOR=/path/to/code-wait.sh

すると編集前にcorntab -eコマンドが終了してしまうのを回避できます。

スクリーンショット 2022-09-16 18.27.15.png

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?