0

I have a cron job for which I want to log output. The cron file (crontab -e) is:

0 7 * * * node $HOME/server/task.js >> $HOME/server/log.txt

The cron task is called:

$ grep CRON /var/log/syslog
Nov  4 07:00:01 ip-... CRON[0000]: (bitnami) CMD (node $HOME/server/task.js >> $HOME/server/task.txt)
Nov  4 07:00:01 ip-... CRON[0000]: (CRON) info (No MTA installed, discarding output)

The line with the error means that I no email installed, but nor do I want to.

The output file is empty when the first line of the NodeJS task uses console.log().

I confirm that the cron job does not run.

How can I debug what is wrong, get cron to run, and save the result to a file?

1 Answer 1

1

By default the output of cron job is mailed to the user which you are executing the script with, reason why you are having No MTA Installed since you don't have any mailing agent installed on your system.

Your script is indeed being executed as seen in the first syslog line. The problem here is within the output that is not redirected to the standard output.

So try to edit your cron job :

   0 7 * * * node $HOME/server/task.js >> $HOME/server/log.txt 2>&1

You must log in to answer this question.

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