The request you are making is odd.
How to show the contents of
/tmp/date.txt
on terminal screen every minute?
How long would you want to see this file? One second, constant, a nanosecond …?
Cron jobs are scripts that run on a periodic basis but are not designed to have live terminal interaction. If you want to have live terminal interaction, you have to perform other actions.
Output generated by cron-jobs, in this case the output of the command /usr/bin/cat /tmp/date.txt
, will be send to your user accounts email. You can check it with the mail
command. Nonetheless, if you want to inspect your file being updated, it is easier to just use the tail -f
command. Just type
$ tail -f /tmp/date.txt
This will update every time /tmp/date.txt
is updated.
Personally, I would change your cronjob into the following:
# Example of job definition:
# .----------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7)
# | | | | |
# * * * * * command to be executed
* * * * * date >> /tmp/date.txt
* * * * * /path/to/script.sh >> /tmp/date.txt
with script.sh
#!/usr/bin/env bash
date
Cronjobs are not difficult, but they can be puzzling sometimes. Fixing errors is generally very easy, but you need to know how to do it. For this I recommend to read the following page:
CLICK HERE to find out more related problems solutions.