cancel
Showing results for 
Search instead for 
Did you mean: 
spurs
Flight Engineer
Flight Engineer
  • 631 Views

Crontab question

Jump to solution

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!

Tags (2)
1 Solution

Accepted Solutions
Chetan_Tiwary_
Community Manager
Community Manager
  • 619 Views

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."

Screenshot from 2023-07-17 22-18-20.png

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.

 

 

 

View solution in original post

2 Replies
Chetan_Tiwary_
Community Manager
Community Manager
  • 620 Views

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."

Screenshot from 2023-07-17 22-18-20.png

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.

 

 

 

spurs
Flight Engineer
Flight Engineer
  • 603 Views

Gotcha, I will try using full path from now on. Cheers

0 Kudos
Join the discussion
You must log in to join this conversation.