...
To set a CRON job in an environment of Composer can be used. Therefore the following configurations must be made:
...
composer.json:
Code Block |
---|
language | xml | linenumbers | true |
---|
|
{
…
"scripts": {
…
"post-install-cmd": [
…
"app/bin/post-setup.sh",
…
],
"post-update-cmd": [
…
"app/bin/post-setup.sh",
…
]
},
…
} |
app/bin/post-setup.sh:
Code Block |
---|
language | bash |
---|
linenumbers | true |
---|
|
#!/bin/bash
cd "$(dirname $(readlink -f "${0}") )"
if [ "$SYMFONY_ENV" = "prod" ]; then
. "${PWD}/_post-setup-prod.sh"
fi
app/bin/_post-setup-prod.sh:
#!/bin/bash
cd "$(dirname $(readlink -f "${0}") )/../../"
…
crontab conf/crontab/crontab-prod
… |
conf/crontab/crontab-prod:
Code Block |
---|
language | bash | linenumbers | true |
---|
|
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * command to be executed
* * * * * cronjob-example |
...