I just created a local cron job on Linux mint. The cron contains the following:
我刚刚在Linux mint上创建了一个本地cron工作。 cron包含以下内容:
*/5 * * * * /home/claudio/crons/autoremove.sh
and the .sh file contains the following:
和.sh文件包含以下内容:
#!/usr/bin/env bash
apt-get autoremove -y
df -h | awk 'NR!=1{print $1, $4, $5}' >> availability.txt
From what I understand, it should run autoremove every 5 minutes and update the availability.txt file with the content of df -h
. But it is not working, I've setup the crontab but every 5 minutes the cron does not run because the availability.txt file is not created.
根据我的理解,它应该每5分钟自动运行一次,并使用df -h的内容更新availability.txt文件。但它不起作用,我已经设置了crontab,但是每隔5分钟cron就不会运行,因为没有创建availability.txt文件。
Any idea of why the script is not running?
知道为什么脚本没有运行?
1 个解决方案
#1
2
Provide absolute path,
提供绝对路径,
df -h | awk 'NR!=1{print $1, $4, $5}' >> availability.txt
use absolute path for availability.txt
使用absolute.txt的绝对路径
df -h | awk 'NR!=1{print $1, $4, $5}' >> /tmp/availability.txt
path from where script is executed plays a role in creating availability.txt,
执行脚本的路径在创建availability.txt中起作用,
#1
2
Provide absolute path,
提供绝对路径,
df -h | awk 'NR!=1{print $1, $4, $5}' >> availability.txt
use absolute path for availability.txt
使用absolute.txt的绝对路径
df -h | awk 'NR!=1{print $1, $4, $5}' >> /tmp/availability.txt
path from where script is executed plays a role in creating availability.txt,
执行脚本的路径在创建availability.txt中起作用,