毎度。一馬力です。
Raspberry PiでCronを使おうと$ crontab -e コマンドをPiで初めて実行してみました。
目次
crontab -eの初回実行→エディタの選択
Raspberry Piで初めて$ crontab -e コマンドを実行すると エディタの選択画面が表示されます。
pi@raspberrypi:~ $ crontab -e no crontab for pi - using an empty one Select an editor. To change later, run 'select-editor'. 1. /bin/ed 2. /bin/nano <---- easiest 3. /usr/bin/vim.tiny Choose 1-3 [2]:
簡単なのは(easiest)は/bin/nanoですよ?って教えてくれるんですが
私はVi使い。
Choose 1-3 [2]: へ3を押してvimを選択しました。
3. /usr/bin/vim.tinyを選択した時の画面
# 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.QSltee/crontab" 22L, 888C
後からエディタを変えたい時はselect-editor
とりあえず。vimを選択。またはオススメに従って/bin/nanoを選択したけど
やっぱり別なエディタが良い!
というときは “$ select-editor”コマンドでエディタを編集できます。
select-editor実行画面
pi@raspberrypi:~ $ select-editor Select an editor. To change later, run 'select-editor'. 1. /bin/ed 2. /bin/nano <---- easiest 3. /usr/bin/vim.tiny Choose 1-3 [2]: 2
初めて”$crontab -e”した時と同じ画面がでますね。
2. /bin/nanoを選択した時の画面
参考までに” /bin/nano ”を選択すると
下のような画面になります。
GNU nano 2.2.6 File: /tmp/crontab.nvzlAO/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 [ Read 22 lines ] ^G Get Help ^O WriteOut ^R Read File ^Y Prev Page ^K Cut Text ^C Cur Pos ^X Exit ^J Justify ^W Where Is ^V Next Page ^U UnCut Text ^T To Spell
/bin/nano使った事ないですが。せっかくなので
試してみようかな?
試した環境
Raspberry Pi 3 Model B Pi 3 Starter Kit 32GB [896-8660-Kit4] Raspbian pi@raspberrypi:~ $ uname -a Linux raspberrypi 4.4.23-v7+ #913 SMP Tue Oct 4 14:16:19 BST 2016 armv7l GNU/Linux pi@raspberrypi:~ $ cat /proc/version Linux version 4.4.23-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611) ) #913 SMP Tue Oct 4 14:16:19 BST 2016 pi@raspberrypi:~ $ lsb_release -a No LSB modules are available. Distributor ID: Raspbian Description: Raspbian GNU/Linux 8.0 (jessie) Release: 8.0 Codename: jessie