crontab -e 簡単な質問

crontab -e 簡単な質問

私は最初にcrontabコマンドに触れましたが、このコマンドの作業中に突然数字を入力し、crontab -eを次のように作成しました。


pi@raspberrypi:~ $ crontab -e
no crontab for pi - using an empty one
889


crontabをデフォルト値に戻したり削除したりする方法はありますか? crontabを使ってタスクを自動化したいです。

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
"/tmp/crontab.QzVh1G/crontab" 23 lines, 898964 characters


あなたの指示に従うと、次のように表示されますexport VISUAL=vi crontab -e。 qaを使う以外はこのファイルを編集できないようです!やめる。私が逃したものはありますか?

ベストアンサー1

エディタが設定されていますed。エディタed非常に基本的な行エディタはファイルを開くとファイルのバイト数を出力します。この例では、crontabファイルには889バイトが含まれています(ファイルの内容を表示するにはエディタで,p入力してクリックします)。Enter

edおそらくあなたはそれをエディタとして使用したくないでしょう(またはあなたがそれを始めたことに気づくでしょう)。エディタを終了するには、を入力してタップするか、またはをq押しEnterますCtrl+D

次に再度実行しcrontab -eVISUAL環境変数をシステムでファイルを編集するために最も一般的に使用されるエディタに設定します。

たとえば、設定方法は次のとおりです。VISUALただし、インストールした他の端末エディタを使用することもできます。vinano

export VISUAL=vi
crontab -e

VISUALシェルの起動ファイルで値を設定する必要があります(~/.bashrcそのファイルを使用している場合bash)。

おすすめ記事