import os

f = open("crontab.txt", "a+")

for parent, dirs, files in os.walk("./"):
    if files and "main" in parent:
        for file in files:
            if file.startswith("run") and "dev" not in file:
                file_p = os.path.join(parent, file)
                proj = file_p.split("/")[1]
                s = file_p.split("run_")[1].split("_")[0]
                method = file_p.split("_")[-1][:-3]
                if method in ["recommend", "hour", "author", "play"]:
                    line = '* * * * * /usr/bin/sh /root/piaoquan_crawler/main/process_mq.sh "{}" "{}" "{}" "prod"'.format(s, proj, method)
                    print(line)
                    f.write(line + "\n")
