Cláudio Ribeiro
Cláudio Ribeiro

Reputation: 1699

Local cron not running every 5 minutes

I just created a local cron job on Linux mint. The cron contains the following:

*/5 * * * * /home/claudio/crons/autoremove.sh

and the .sh file contains the following:

#!/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.

Any idea of why the script is not running?

Upvotes: 0

Views: 1453

Answers (1)

asio_guy
asio_guy

Reputation: 3767

Provide absolute path,

df -h | awk 'NR!=1{print $1, $4, $5}' >> availability.txt

use absolute path for availability.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,

Upvotes: 2

Related Questions