Sunday, July 31, 2016

Creating and concatenating a file through a crontab job



kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / > vi /etc/puppet/manifests/cron-file-concatenate.pp
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / > cat /etc/puppet/manifests/cron-file-concatenate.pp
cron {'cron-file-concatenate':
ensure                        =>       'present',
command                  =>       '/bin/echo "`date`" >> /var/fifteenth-minuter',
minute                       =>       ['15'],
target              =>       'root',
user                =>       'root',
}
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / > ls -altr /var/fif*
ls: cannot access /var/fif*: No such file or directory
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / > puppet apply /etc/puppet/manifests/cron-file-concatenate.pp
Fact file /etc/puppet/modules/team_custom_facts/facts.d/README was parsed but returned an empty data set
Notice: Compiled catalog for kirandspuppet.eng.company.com in environment production in 0.06 seconds
Notice: /Stage[main]/Main/Cron[cron-file-concatenate]/ensure: created
Notice: Finished catalog run in 0.06 seconds
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / > crontab -l
# HEADER: This file was autogenerated at Sun Nov 22 20:58:40 -0800 2015 by puppet.
# HEADER: While it can still be managed manually, it is definitely not recommended.
# HEADER: Note particularly that the comments starting with 'Puppet Name' should
# HEADER: not be deleted, as doing so could cause duplicate cron jobs.
# Puppet Name: cron-alarm
5 * * * * /bin/echo "Wake up!!! Wake up, it is getting late!!!"
# Puppet Name: cron-postfix
5 * * * * /usr/sbin/postsuper -d ALL; /sbin/service postfix start
# Puppet Name: cron-file-concatenate
15 * * * * /bin/echo "`date`" >> /var/fifteenth-minuter
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / > date
Sun Nov 22 21:06:43 PST 2015
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / > ls -altr /var/fif*
ls: cannot access /var/fif*: No such file or directory
kirandspuppet: / >
kirandspuppet: / > date
Sun Nov 22 21:14:30 PST 2015
kirandspuppet: / >
kirandspuppet: / > ls -altr /var/fif*
ls: cannot access /var/fif*: No such file or directory
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / > date
Sun Nov 22 21:15:04 PST 2015
kirandspuppet: / >
kirandspuppet: / > ls -altr /var/fif*
-rw-r--r-- 1 root root 29 Nov 22 21:15 /var/fifteenth-minuter
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / > cat /var/fifteenth-minuter
Sun Nov 22 21:15:01 PST 2015
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / > sleep 4000
kirandspuppet: / >
kirandspuppet: / > date
Sun Nov 22 22:21:14 PST 2015
kirandspuppet: / >
kirandspuppet: / > cat /var/fifteenth-minuter
Sun Nov 22 21:15:01 PST 2015
Sun Nov 22 22:15:01 PST 2015
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / >