Saturday, March 16, 2019

Linux shell scripting for cron jobs

Linux shell scripting for cron jobs


List available shells
cat etc/shells

Where is bash located
which bash

Create script file
touch clea-ram.sh

#! /bin/bash
su -c "echo 1 >'/proc/sys/vm/drop_caches' && swapoff -a && swapon -a && printf '\n%s\n' 'Ram-cache and Swap Cleared'" root

to save file in nano
Ctrl + x
yes
enter
cat to see content

chmod +x clear-ram.sh
We want these permissions
-rwxrwxr-x
or

chmod 775  clear-ram.sh

Running cron jobs from crontab -e)
add this line to crontab
0 3 * * * /home/scripts/clear-ram.sh

crontab -l to view



As per video 
https://youtu.be/cQepf9fY6cE


IT Consultant

www.inCOREporation.com

No comments:

Post a Comment

Featured Posts

Exchange Online Limits - Office 365 Distribution group limits

Exchange Online Limits - Office 365 Distribution group limits What are Exchange Online Limits What are Office 365 Distribution group limi...