Open kdmgs110 opened 6 years ago
停止していた
$ ps -aef | grep cron
ので、実行した
$ sudo service cron start
https://review-of-my-life.blogspot.jp/2018/04/python3-crontab.html
$ cat autoLike.log
を行っても、ログ出力されない$ 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
python3 autoLike.py progate
で実行した結果、うまくいっている。
なので、autoLike.pyが壊れているわけではなさそう。本来の期待値:
結果:
ref #23 こっちではできとるみたいなのだが何がおかしいんだろうか。
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を新しく追加しました")
ref #31 crontabの設定はもろもろできたので、次はログ出力を行えるようにしたいところ。