Skip to content

Instantly share code, notes, and snippets.

@muse-sisay
Last active September 4, 2021 13:41
Show Gist options
  • Save muse-sisay/9e8ac538aa4a9af6f60f1694f586ddba to your computer and use it in GitHub Desktop.
Save muse-sisay/9e8ac538aa4a9af6f60f1694f586ddba to your computer and use it in GitHub Desktop.
LFCS objective: Scheduling Tasks with cron & Managing Swap space

Scheduling Tasks with cron

minute hour day_of_month month day_of_week $USER COMMAND

  • man 5 cron for explanation
  • /var/spool/cron directory where cron checks for user jobs

Handy way of having a reference.

$ cat /etc/crontab >> /var/spool/cron/$USER
*/15 12 * * * logger "doing something"

this would run it every 15 minutes starting from 12:00 o'clock (24 hour format) till 13:00. 12:00, 12:15, 12:30, 12:45

15 12 15 * Fri logger "doing something"

runs the command on the 15th of every month, and every Friday at 12:15

note: When the Day of month and Day of week fields are both other than *, the command is executed when either of these two fields are satisfied

cron.allow and cron.deny files

  • if /etc/cron.deny exists it will implicity allow users not listed to run /etc/crontab -e and will explicity disallow users listed.

  • if cron.allow exists it will only allow user listed in the file and explicity disallow user not listed from running crontab -e

  • if neither file exist only the root user is allowed to run crontab -e

. cron.deny exists cron.deny does not exist
cron.allow exist only user listed in cron.allow are allowed only user listed in cron.allow are allowed
cron.allow does not exist user listed in cron.deny aren't allowed only root user can use crontab -e

Swap space

  • We can have a file or partition as a swap space.

  • The steps for addin a swap space is

    • prepare a file or partition
    • run mkswap on the file or partition
    • run swapon on the file or partition
    • add the the file or partition to /etc/fstab (optional)
  • swapon -s or free -h are some of the commands to view swap space

  • dd or fallocate can be used to create a swap file. (dd command is recommend,trust me )


Tonight's Presenters

  • Bismarck Mosioma on _Schedule tasks to run at a set date and time _
  • Muse Sisay on Configure and manage swap space and Setup user and group disk quotas for filesystems

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment