0

I'm trying to get a success&error log, but no logging. My environment is Amazon Linux 2.

/etc/crontab */1 * * * * /home/ec2-user/gaMain.sh >> /var/log/galog.log 2>&1

/var/log/cron (ec2-user) CMD (/home/ec2-user/gaMain.sh >> /var/log/galog.log 2>&1)

So, the cron is running.

I expect the output of command sudo less /var/log/galog.log, but i I get a error:

There is no file that name

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • I wonder if the cron job does not have permission to write to `/var/log`? Can you try saving the log in `/tmp` instead, and see whether that works? – John Rotenstein Jul 18 '19 at 10:00
  • Thanks.I tried saving the log in /tmp and I got success. But, I can't change the permission to write a log in /var/log, how can I do? – kkein 81e Jul 23 '19 at 07:27
  • It sounds like the cron task is running as a user that is not permitted to write to that location. Either try putting `sudo` in the cron command (`sudo /home/ec2-user/gaMain.sh >> /var/log/galog.log 2>&1`) or create the crontab under the `root` user. – John Rotenstein Jul 23 '19 at 18:51

0 Answers0