0

提取.py

def extract_lz4(lz4_path):
    status = subprocess.call(["lz4", "-df", lz4_path], stderr=subprocess.STDOUT)
    log.info("In Extract fun STATUS : {}".format(status))
    if not status:
        log.info("Extract Successful of {}".format(lz4_path))
        return status
    else:
        log.info("Extract Successful of {}".format(lz4_path))
        return status

主要.py

 lz4_file = '<path-to-lz4-file>/ly486imc83e0v9a7-23-telnet-banner-full_ipv4-20180515T040003-zmap-results.csv.lz4'

 extract_status = extract_lz4_task(lz4_file)
 log.info("extract_status : {}".format(extract_status))

当我调用主文件时,python <path-to-file>/main.py它将成功提取。但是当我把它放在 crontab 中时,它不会提取.

crontab -e

* * * * * python <path-to-file>/main.py

有什么我想念的吗?任何帮助将不胜感激

4

1 回答 1

0

尝试使用以下命令调试您的 cron:

tail /var/log/cron

或者添加日志文件

$ crontab -e
  * * * * * python <path-to-file>/main.py >> <path-to-file>/cron.log 2>&1
于 2018-06-18T12:25:09.997 回答