I can't understand, I have looked at several forums to help me, etc... But it still doesn't work!
I would like to run a script thanks to Cron!
To try, I'm currently trying to execute a script that sends "test" in commands (with echo test). No problem, this script works perfectly by hand if I call the file.
But I tried to run my file with Crontab -e
every minute and I've been waiting for several minutes already, but no results.
And I can't really understand why!
Already, I was told to put #! /bin/bash
at the beginning of my code in my script, but when I put it in I have an error and the code doesn't execute by hand. Whereas if I don't put anything in, the code runs smoothly.
So I don't know if that's where the mistake came from, maybe.....
The final goal would be to make a script that runs every day, say to clear the cache with sync; echo 3 > /proc/sys/vm/drop_caches
.
What should look like in the Crontab : 00 20 * * * PATH
if I'm not mistaken.
Do you have a solution to help me?
EDIT: -bash: /root/Discord/script/cache.sh: /bin/bash^M: bad interpreter: No such file or directory
it's the error I got when I runned /root/Discord/script/cache.sh
to execut my script. And that command works when I don't have #! /bin/bash
. But that works when I used sh cache.sh
in the directory, even with #! /bin/bash
!