3
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 5 years have passed since last update.

Ubuntu1804で起動時にコマンドを実行する

Last updated at Posted at 2019-06-05

概要

VMにMinikubeくん🐳を作った。
クラウドの課金をケチるために使わないときは落としたかった。
VMを一度落とすとMinikubeくん🐳が止まるので、起動時に自動的に立ち上げたかった。
Ubuntuさん初めてなんでお手柔らかにお願いします。

方法

crontab -e

初回はテキストエディターを選ぶ画面が表示される。
Ubuntuさんが声高にオススメだとおっしゃるので議論の余地なくnanoを選択。
(vi/vimみたいにi,aをせずにそのままテキスト編集、Ctrl+oで保存、Ctrl+xで終了)。

以下を追加して保存。

@reboot sudo minikube start --vm-driver=none

修正内容が正しく反映されてるかは以下。

crontab -l

ちゃんとでてくるので良さそう。


root@container-01:~# crontab -l
# 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

@reboot sudo minikube start --vm-driver=none

再起動してみてMinikubeが立ち上がってればOK。

root@container-01:~# minikube status
host: Running
kubelet: Running
apiserver: Running
kubectl: Correctly Configured: pointing to minikube-vm at <your IP>

Ubuntuさん、あざっした。
Minikubeくんもご苦労🐳
ちゃんちゃん。

参考

3
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
3
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?