I have python and node scripts set as cron jobs on EC2. The python scripts run but the node scripts do not run. The node scripts run fine when activated manually from the command line. This is a simple script that finds out if today is a holiday and then puts the boolian answer into a file named isHoliday.csv.
What I've tried so far:
I see the log file is named holiday_script.log in the sudo cron, and holiday.log in the cron.d file, but neither log file has been created.
Code in the holiday.js file:
// Check if it is a holiday, t/f
var holidayChecker = require('usa-holidays');
var date = new Date();
var holidayObj = holidayChecker.make(date);
var isHoliday = !holidayObj.isBusinessDay();
// put the answer into a file so it can be read by python crons
var fs = require('fs');
fs.writeFile("/home/ec2-user/stack/isHoliday.csv", isHoliday, function(err) {
if(err) {
return console.log(err);
}
});
I don't know the exact solution, but you can view your cron logs by moving to a different directory. When you first login to EC2, do this twice: cd ..
That will take you up two directories. Then you'll need to switch user to sudo like this: sudo su
Then move to the var/log folder. There should be a file named "cron". Since you have crons setup as *****, that file should be filling up with data every second. Tail it by typing: tail -f cron
. That will allow you to see the crons execute in real time.
Also, the "mail" notice: navigate to that folder and use less
to read the mail. That file will have more clues. Scroll down with the down-arrow.
That isn't the answer but it will help you move forward a bit.