When I look at the questions and answers on this forum, it seems like the threshold to ask a question is very high. At least for someone like me, with very little knowledge of Linux. Most of the questions about cron jobs are out of my league, including the answers. So with a little bit of embarrassment, I am going to ask the simplest questions.

I want to create a cron job that shows me the data/time every minute. I want to see this in real time, on the console. I am guessing that this will eventually be done through a bash script or Python, but for now, I want to use the command line.

crontab -e
* * * * * /bin/date >> /home/pi/cron_date

I understand the concept of the stars. I have used the "which" command to find where "date" is. I am redirecting this "date" information to a file which has not been created yet, but will be created when I hit the Enter key, called cron_date.

I am using the editor "nano". Control + O is WriteOut (which I am guessing is save/save as).

File Name to Write: /tmp/crontab.D3AZm/crontab

Question 1: I have used the Enter key and let "nano" call it what it wants to. My cron_date file is still created under /home/pi. I understand that the file name "nano" is giving me is for a temporary file. But since I already have decided that I want this file as my own file, should I delete the "nano" suggestion and substitute it with:

File Name to Write: /home/pi/cron_date

or am I wondering about things I really don't have to think about? For now, I have been letting this temp file be named by "nano" and not substituting anything.

crontab: installing new crontab
crontab -l

My file exists. The problem now is viewing the file realtime. I can see the date/time with:

nano cron_date
cat /home/pi/cron_date

But I have to use the same commands to update the information. My only realtime view of this file is:

tail -f /home/pi/cron_date

Question 2: Is there a way where I can see the whole file being updated?

This is just the beginning of a hobby project I want to do. Take pictures with a Raspberry Pi of the bottom of a river. I will be making an amateur ROV. If my Raspberry Pi with camera is submerged under water, I want to measure the temp combined with the time. If it overheats I will be able to see that and turn on a fan. I might be barking up the wrong tree, but my understanding of cron jobs is where my project starts.

Raspberry Pi 1 model B: Which uses Debian.

1 Answer 1


When you run the crontab -e command, it lets you edit a temporary file. When you exit the editor, the temporary file is checked for syntax errors, and if there aren't any, it's installed in the system directory that contains users' crontabs. If you save the file to a different location, then the temporary file will not be modified, and thus your previous crontab remains in place. Run the command crontab -l to check the content of your crontab.

Each cron job is executed in your home directory. This is completely independent of the location of the temporary file that you edit. If you want a job to be executed in a different directory, start it with the cd command, e.g.

* * * * * cd ~/subdir && date >>somefile

This changes to the directory subdir in your home directory (which must already exist), and the output of date will thus be written to /home/pi/subdir/somefile. If the cd command fails (e.g. because the directory doesn't exist), the date command won't be executed, thanks to the && operator.

You don't need to write the full path to date, because it's in the default command search path.

I'm not sure what you mean by “see the whole file being updated”. The command tail -f shows the last 10 lines of the file at the time it is executed, then keeps running forever (or until you kill it) and shows lines as they are added. If you want to show only newly-added line (i.e. don't show anything when tail starts, tell it to output 0 lines:

tail -n 0 -f /home/pi/cron_date

If you want to show the whole file, and then print new lines as they are added, tell tail to start at line 1.

tail -n +1 -f /home/pi/cron_date

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .