kdmgs110 / Tweet-Analyser

Flaskでつくれるツイート分析アプリです。
4 stars 0 forks source link

ログ出力ができているのかわからないのでログファイルの設定を行えるように、cron側で設定する #32

Open kdmgs110 opened 6 years ago

kdmgs110 commented 6 years ago

ref #31 crontabの設定はもろもろできたので、次はログ出力を行えるようにしたいところ。

kdmgs110 commented 6 years ago

停止していた

$ ps -aef | grep cron

ので、実行した

$ sudo service cron start

https://review-of-my-life.blogspot.jp/2018/04/python3-crontab.html

kdmgs110 commented 6 years ago
$ crontab -l

kdmgs110@DESKTOP-4HHEO95:/mnt/c/workspace/pydev/tweet-analyser$ 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

* * * * * python3 /mnt/c/workspace/pydev/tweet-analyser/autolike.py Progate >> /mnt/c/workspace/pydev/tweet-analyser/autolike.log
kdmgs110 commented 6 years ago

python3 autoLike.py progateで実行した結果、うまくいっている。 なので、autoLike.pyが壊れているわけではなさそう。

本来の期待値:

結果:

kdmgs110 commented 6 years ago

ref #23 こっちではできとるみたいなのだが何がおかしいんだろうか。

kdmgs110 commented 6 years ago

def addCronTab(query, crontab):
    cron = CronTab(user=True)
    cwd = os.getcwd()
    job = cron.new(command = "python3 {}/autoLike.py {} >> {}/autolike.log".format(cwd, query, cwd))
    job.enable(False)
    cron.write()
    print("[INFO] crontabを新しく追加しました")