How to set crontab when using AWS CloudFormation Userdata?
I am setting
(crontab -l ; echo \"0 * * * * wget -O - -q http://www.example.com/cron.php\") |
I had similar issue like others are saying here that these commands work fine from CLI but when added through userdata not working. After several hours of head scratching search finally realized I had to add line "#!/bin/bash" before crontab setup commands. This fixed my problem, some very well experienced people might know this already but if you are bit new to this realm may not know this. My script look like below.
!/bin/bash sudo su echo '*/1 * * * * command1 command2' > /tmp/mycrontab.txt sudo -u ubuntu bash -c 'crontab /tmp/mycrontab.txt'