LoginSignup
4
3

More than 5 years have passed since last update.

ubuntu 再起動でpidファイルディレクトリ消える対処

Last updated at Posted at 2014-09-19

今回はmongodbのpidファイルだが、他も多分同じように消える。
→ubuntu の tmpfs (temporary file system)

再起動すると、mongodbのpidファイルが置いてある/var/run/mongodbのmongodbディレクトリが消える。その対処。

/var/run -> /run
というようにシンボリックリンクになっているので、mongodbディレクトリを作成して、シンボリックリンク貼れば行けるかと思ったが、できなかった。
ので、start up scriptを作成。

pid_dir.sh
#!/bin/sh
mkdir -p /var/run/mongodb
cd /var/run
sudo chown -R mongodb:mongodb mongodb/

実行権限与える。 chmod u+x pid_dir.sh

これをcronでreboot時に実行されるようにする。

sudo crontab -e


# 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 /home/ubuntu/bin/pid_dir.sh

他にいい方法あったら教えてください!

4
3
1

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