'Cron -bash: 0: command not found

I feel very dumb but why does it not work when I just want to use a simple Linux command in a crontab?

0 0 0 * * ? ls /data/synology/multimedia/movies > /data/storage/backup/movies.txt 2>&1

This ends up in -bash: 0: command not found. Why is ls not found? What is wrong?



Solution 1:[1]

You are not specifying a command to bash. It thinks 0 is the name of the program you want to run.

Solution 2:[2]

try this one. use absolute path of ls .

first of all find the absolute path with whereis ls then add crontab as below.

0 0 0 * * /bin/ls /data/synology/multimedia/movies > /data/storage/backup/movies.txt 2>&1

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kyriazis
Solution 2