This gist is a snippet for creating any scripts, it contains the default support for property env files and logger on specific location
-
Create a respective env property files, as of now we support
local.properties
,dev.properties
,stag.properties
andprod.properties
, you can use example.properties for default properties and on top of that, you can add more and update the script accordingly -
Add your properties to respective property files and update the script accordingly to get the property
-
Create logger.properties from example-logger.properties file and update the logger path where you want to dump your logs
-
Now to run the script you can use any follows commands to run this script, before running just make sure all the script has executable permission (
chmod +x script.sh logger.sh
etc..)# Command > ./script.sh --target [ENV_NAME] # Examples ./script.sh # Default would be local env means local.properties will be used, make sure you have it ./script.sh --target dev # Targeting develop environment ./script.sh --target stag # Targeting staging environment ./script.sh --target prod # Targeting production environment
-
Now you can add your code in
_start_
function in script.sh file. -
That's it, Now, validate the logs folder and check if everything looks fine.
-
If you want to setup a crontab for this script, please use below command after
crontab -e
# Command (For Every 5 Minutes CRONJOB) */5 * * * * /[FULL_PATH_TO_SCRIPT]/script.sh --target [ENV_NAME] # Examples 1 (For Every 5 Minutes CRONJOB) */5 * * * * /opt/script/script.sh --target dev # Example 2 (This will run job at 12:00 am every day) 0 0 * * * /opt/script/script.sh --target stag
- Improve Logger
- UPDATE README.md