Skip to content
Advertisement

crontab not working under arch linux

I tried to set up a schedule to remove the old file and folder after several days. I put the following code in a script file and tried to use crontab to run it every day. The find command worked fine. but the crontab seems not execute the script file.

I also use crontab for other tasks, i.e. rsync, they all work fine. I am wondering what might be the possible reason that crontab won’t work in this case. And what could I do alternatively for the job? Thanks!

#!/bin/bash -x

find /media -type d -ctime +18 | xargs rm -rf

my crontab entries are

10 09 * * * /root/rsync-shell.sh &
20 09 * * * /root/chg3gp2avi.sh &
30 09 * * * /root/clean_files_10days.sh &

the first two are the ones I set up before and work fine. The third one is the current one that won’t work.

Advertisement

Answer

Is crond running?

$ systemctl status crond
* crond.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)

If not try to start it before debugging any further. If you have not configured sudo then use root privileges by some other means, such as logging in as root or via su command.

$ sudo systemctl start crond
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement