2

So I created a cronjob that looks like this:

*/1 * * * * echo 'hello world' 2>&1 >> ~/logs/test.log

But when I check the ~/logs/test.log I don't see anything logged. What am I doing wrong? Every resource I found on the internet show a similar solution, including this one

Community
  • 1
  • 1

1 Answers1

3

The cron job is executed by the system, so the ~/ shortcut might either be undefined or point to /root/.

TeTeT
  • 2,044
  • 20
  • 30
  • I wasted so much time trying to find what was wrong with my job, and this was it. ~/ will point to the home directory for whatever user you are running the script as, in my case root. It does not point to the home directory of the default user. – Remolten Mar 28 '17 at 17:18