| | 179 | ===== How to execute commands with back ticks ===== |
| | 180 | |
| | 181 | If you need to include the output of a complex command in your script, you can write the statement inside back ticks. |
| | 182 | |
| | 183 | syntax: |
| | 184 | |
| | 185 | {{{ |
| | 186 | var= ` commands ` |
| | 187 | }}} |
| | 188 | |
| | 189 | Example: Suppose we want to get the output of a list of mountpoints with tmpfs in their name. We can craft a statement like this: df -h | grep tmpfs. |
| | 190 | |
| | 191 | {{{ |
| | 192 | #!/bin/bash |
| | 193 | |
| | 194 | var=`df -h | grep tmpfs` |
| | 195 | echo $var |
| | 196 | }}} |
| | 197 | |
| | 198 | ===== How to Automate Scripts by Scheduling via cron Jobs ===== |
| | 199 | |
| | 200 | Cron is a job scheduling utility present in Unix like systems. Jobs can be scheduled to execute daily, weekly, monthly or in a specific time of the day. Automation in Linux heavily relies on cron jobs. |
| | 201 | |
| | 202 | Below is the syntax to schedule crons: |
| | 203 | |
| | 204 | {{{ |
| | 205 | # Cron job example |
| | 206 | * * * * * sh /path/to/script.sh |
| | 207 | }}} |
| | 208 | |
| | 209 | Here, * represent represents minute(s) hour(s) day(s) month(s) weekday(s), respectively. |