Using Cron keep your eyes in check

basic syntax for cron

a typical cron job looks like this

# m h dom mon dow command
* * * * * /usr/bin/sh ls

stand for wildcard
this is not a cron tutorial this is just how i use it.

eyes.sh script

the bas…


This content originally appeared on DEV Community and was authored by has12zen

basic syntax for cron

a typical cron job looks like this

# m h  dom mon dow   command
  * *   *   *   *   /usr/bin/sh ls
  • stand for wildcard this is not a cron tutorial this is just how i use it.

eyes.sh script

the bash script looks like

#!/bin/sh
export DISPLAY=:0
notify-send "EYES CHECK" "Look away for 15 seconds"

without line no 2 it wont work as it sets the display for notify-send. I am using notify-send as my notification daemon.

make sure that your display is :0
you can do this with

echo $DISPLAY

setting up crontab

first you will need to make sure cron is running you can do this by:

systemctl status cronie

p.s. this is specific to arch based system.

once cron is running you can create/edit cron job with crontab -e

then paste the code present below into the window.

*/15 * * * * /usr/bin/sh  /home/elnovo/.noti/eyes.sh

it runs every 15 min and eyes.sh is the bash script we discussed above. save it.
you can find the cron jobs currently present by crontab -l

sources

notify-send doesn't work from crontab


This content originally appeared on DEV Community and was authored by has12zen


Print Share Comment Cite Upload Translate Updates
APA

has12zen | Sciencx (2021-09-26T16:42:57+00:00) Using Cron keep your eyes in check. Retrieved from https://www.scien.cx/2021/09/26/using-cron-keep-your-eyes-in-check/

MLA
" » Using Cron keep your eyes in check." has12zen | Sciencx - Sunday September 26, 2021, https://www.scien.cx/2021/09/26/using-cron-keep-your-eyes-in-check/
HARVARD
has12zen | Sciencx Sunday September 26, 2021 » Using Cron keep your eyes in check., viewed ,<https://www.scien.cx/2021/09/26/using-cron-keep-your-eyes-in-check/>
VANCOUVER
has12zen | Sciencx - » Using Cron keep your eyes in check. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/09/26/using-cron-keep-your-eyes-in-check/
CHICAGO
" » Using Cron keep your eyes in check." has12zen | Sciencx - Accessed . https://www.scien.cx/2021/09/26/using-cron-keep-your-eyes-in-check/
IEEE
" » Using Cron keep your eyes in check." has12zen | Sciencx [Online]. Available: https://www.scien.cx/2021/09/26/using-cron-keep-your-eyes-in-check/. [Accessed: ]
rf:citation
» Using Cron keep your eyes in check | has12zen | Sciencx | https://www.scien.cx/2021/09/26/using-cron-keep-your-eyes-in-check/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.