Hello guys! I am new to crontab. I now created a simple crontab job. It should execute every 15 minutes to alert me that I need to take a short break. However, it does not work. I don't know why. Please help me if you have experience with crontab. I used the command crontab -e to create this file and save it.
# Edit this file to introduce tasks to be run by cron. # # Each task to run has to be defined through a single line # indicating with different fields when the task will be run # and what command to run for the task # # To define the time you can provide concrete values for # minute (m), hour (h), day of month (dom), month (mon), # and day of week (dow) or use '*' in these fields (for 'any').# # Notice that tasks will be started based on the cron's system # daemon's notion of time and timezones. # # Output of the crontab jobs (including errors) is sent through # email to the user the crontab file belongs to (unless redirected). # # For example, you can run a backup of all your user accounts # at 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # For more information see the manual pages of crontab(5) and cron(8) # */15 * * * * /home/galaxy/Documents/projects/Bash/cron_job.sh
This file is supposed to execute the script cron_job.sh every 15 minutes. This is a Bash shell script that has a chmod value of 500. It contains one command to create a new gnome-terminal and immediately run a command inside that new terminal to cat the file take_a_break. That is a text file with a simple message telling me to take a break. Either running the shell script or just running the command contained inside of it works flawlessly, but the crontab job does not work at all. Maybe I formatted something incorrectly. Here is the contents of the file cron_job.sh;
#!/bin/bash gnome-terminal -e "bash -c \"cat $HOME/Documents/ascii/take_a_break; exec bash\""