How to execute the command in cronjob to display the output in terminal

You can't do this.

All cron jobs are run in non-interactive shells, there is no terminal attachment. Hence the concept of /dev/tty or similar is not available in cron.


The dirty way could be to redirect the output of your program to the pts file of an already existing terminal.

To know the pts file just type tty command

~$ tty  
/dev/pts/19

then your crontab would be:

* * * * * /usr/local/scripts/script.sh > /dev/pts/19

Tags:

Cron