Hello!
to echo hello every 3 minutes
what I thought was
*/3 * * * * echo hello
but actually the answer on the website was
*/3 * * * * /bin/echo hello
I've got two questions here,
1.for the command should it be always [location of the command]?
ex,if touch file, should it be */3 * * * /bin/touch ?
2. if it should be location of the command, why it's not /usr/bin/echo? can /usr be left out?
Thanks in advance!
Hello @spurs !
Thanks for reaching out!
It is always recommended and a good practice to mention the exact ( full ) path of the command or the script to be executed by the cron daemon :
refer this blog : https://www.redhat.com/sysadmin/automate-linux-tasks-cron
Refer here for /bin : https://www.pathname.com/fhs/pub/fhs-2.3.html#BINESSENTIALUSERCOMMANDBINARIES
" /bin contains commands that may be used by both the system administrator and by users, and in single user mode. It may also contain commands which are used indirectly by scripts"
refer here for /usr/bin : https://www.pathname.com/fhs/pub/fhs-2.3.html#USRBINMOSTUSERCOMMANDS
" /usr/bin : This is the primary directory of executable commands on the system."
You must specify the full path to all commands not in the default PATH, and always specify the full path for files. If you do not know it just run "#which <cmd-name>" and then include that in the crontab entry.
Hello @spurs !
Thanks for reaching out!
It is always recommended and a good practice to mention the exact ( full ) path of the command or the script to be executed by the cron daemon :
refer this blog : https://www.redhat.com/sysadmin/automate-linux-tasks-cron
Refer here for /bin : https://www.pathname.com/fhs/pub/fhs-2.3.html#BINESSENTIALUSERCOMMANDBINARIES
" /bin contains commands that may be used by both the system administrator and by users, and in single user mode. It may also contain commands which are used indirectly by scripts"
refer here for /usr/bin : https://www.pathname.com/fhs/pub/fhs-2.3.html#USRBINMOSTUSERCOMMANDS
" /usr/bin : This is the primary directory of executable commands on the system."
You must specify the full path to all commands not in the default PATH, and always specify the full path for files. If you do not know it just run "#which <cmd-name>" and then include that in the crontab entry.
Gotcha, I will try using full path from now on. Cheers
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.