I want to test a crontab job by writing the date to a text file every minute as the following script shows:
#!/bin/bash
date >> /home/SomeUserName/Desktop/date.txt
This almost accomplishes what I want but I don't want my script to overwrite the file in each iteration. So I used >> instead of > because I thought that it would only append to the file. Although, every time crontab executes the script I can only see one date.
Why is that so happening?
I am using linux mint.
I can confirm that it should work as expected.
Created a script /home/myuser/xd.sh:
#!/bin/bash
date >> $HOME/date.txt
and a crontab (via crontab -e):
# m h dom mon dow command
* * * * * /home/myuser/xd.sh
Then I see the expected result:
$ cat date.txt
Sa 16. Jul 02:02:01 CEST 2016
Sa 16. Jul 02:03:01 CEST 2016
Sa 16. Jul 02:04:01 CEST 2016
Sa 16. Jul 02:05:01 CEST 2016
Sa 16. Jul 02:06:01 CEST 2016
Sa 16. Jul 02:07:01 CEST 2016
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With