LoginSignup
0
0

More than 5 years have passed since last update.

CentOS 6.9 上で gsutil コマンドを crontab から動かすまで

Posted at

コマンドラインからは gsutil コマンドを含むスクリプトを実行できるのだが、そのスクリプトを crontab に登録して実行すると動いているようで実は gsutil がエラーを吐いていて実行されていなかったというオチでした。。。
いろんなサイトを検索しまくって断片的な情報を調べることになったので、まとめておきます。

現時点で、gsutil は python2.7 が必要。

ところが CentOS 6.9 では python 2.6 がインストールされており、しかも yum コマンドが python 2.6 で動いている。python 2.7 で動かすとエラーが出る。

OS確認
# cat /etc/redhat-release
CentOS release 6.9 (Final)

現在の バージョン
# python -V
Python 2.6.6

まずデフォルトのpythonをリネームして寄せておく
# mv /usr/bin/python /usr/bin/python2.6.6

python 2.7 をソースからインストールして差し替える形で配置
# cd /usr/local/src
# curl -O https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz
# tar zxf Python-2.7.15.tgz
# cd Python-2.7.15
# ./configure
# make && make altinstall
# cp /usr/local/src/Python-2.7.15/python /usr/bin/python

yum コマンドを実行する python を リネームしておいた 2.6.6 を指定
# vim /usr/bin/yum の1行目
---------------------------
#!/usr/bin/python

#!/usr/bin/python2.6.6
---------------------------

動作確認
# yum list
⇒動いたので問題なし

ついでに

gsutil が動いたと思ったら sqlite3 が無いというエラーも出ました。。

sqlite を yum でインストールする
# yum install sqlite-*

以上で、Google Play Store のレポートデータを cron でゲットしてデータをゴニョることができました。

感想
CentOS はもう 7系を使えってことですかね。。

0
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
0
0