I set to output the log of cron execution to a log file.
Ubuntu 16.04.5 LTS
Open this file.
By default, this line should be commented, so uncomment and update.
However, it could not be updated because it was Read Only. Change the permissions so that you can write.
sudo chmod 646 /etc/rsyslog.d/50-default.conf (Change before)-rw-r--r-- (After change)-rw-r--rw-
The cron log is output by rsyslog. The rsyslog service must be restarted for the above settings to take effect.
service rsyslog restart
Make sure that the service is started just in case.
service --status-all | grep rsyslog
The log will be output here. rsyslog will write the cron log for you. A new cron.log is created when the first log is written to cron.log.
Add the following two lines with ** crontab -e **.
1 12 * * * cd $HOME && date "+\%Y/\%m/\%d \%H:\%M:\%S" >> ./syori01.log 2 12 * * * cd $HOME && /usr/local/rbenv/shims/ruby syori01.rb >> ./syori01.log
At 12:01, write the system date and time to syori01.log, and then at 12:02, execute the ruby program called syori01.rb and output it to syori01.log as standard. The caveat is that if you specify a date in cron, it won't work unless you escape the%.
・ To find the place where ruby is stored, do ** which ruby **. -This process is executed in the Home directory.