Cannot install crontab using shell provisioner on an EC2 instance

882 views
Skip to first unread message

Stan Svec

unread,
Aug 10, 2017, 2:43:26 PM8/10/17
to Packer
I'm trying to install crontab on an AMI image using the shell provisioner like this:
{
 
"type": "shell",
 
"skip_clean": true,
 
"inline": [
   
"some commands above and here and then..",
   
"(crontab -l 2> /dev/null; echo '0 03 * * * /home/ec2-user/cron/some-script.sh') | crontab -"
 
]
}
SSH username in the builder is set to ec2-user. The problem is that when I create an instance from the image and log in I cannot see any cron installed by checking with crontab -l. However when I keep the script on the image by setting skip_clean to true and execute the script again manually (as ec2-user) then the cron entry is set up. That seems strange to me, because all other commands in the inline sections execute just fine. Any thoughts please?

Thanks,

Stan

Rickard von Essen

unread,
Aug 10, 2017, 3:15:13 PM8/10/17
to packe...@googlegroups.com
Just drop your cronfile into /etc/cron.d/ see https://help.ubuntu.com/community/CronHowto#Two_Other_Types_of_Crontab

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/a630d63d-e6b2-4f93-96c2-d319f5ff1163%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stan Svec

unread,
Aug 11, 2017, 10:26:56 AM8/11/17
to Packer
I'll do it as you suggest. Thanks.


On Thursday, 10 August 2017 20:15:13 UTC+1, Rickard von Essen wrote:
Just drop your cronfile into /etc/cron.d/ see https://help.ubuntu.com/community/CronHowto#Two_Other_Types_of_Crontab
On Aug 10, 2017 20:43, "Stan Svec" <stan....@gmail.com> wrote:
I'm trying to install crontab on an AMI image using the shell provisioner like this:
{
 
"type": "shell",
 
"skip_clean": true,
 
"inline": [
   
"some commands above and here and then..",
   
"(crontab -l 2> /dev/null; echo '0 03 * * * /home/ec2-user/cron/some-script.sh') | crontab -"
 
]
}
SSH username in the builder is set to ec2-user. The problem is that when I create an instance from the image and log in I cannot see any cron installed by checking with crontab -l. However when I keep the script on the image by setting skip_clean to true and execute the script again manually (as ec2-user) then the cron entry is set up. That seems strange to me, because all other commands in the inline sections execute just fine. Any thoughts please?

Thanks,

Stan

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages