did cron job run

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
kaykav

did cron job run

Post by kaykav »

Hi
I've been trying to understand man pages,unsuccessfully. I would like to know what command I can use to determine when ,if at all, my scheduled cron job was run.
my crontab entry is; 35 * * * * /home/kaykav/bin/ups.sh .So my script should run at 35 mins after every hour. How do I know if it runs as scheduled? thanks..
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
Pilosopong Tasyo
Level 6
Level 6
Posts: 1432
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines

Re: did cron job run

Post by Pilosopong Tasyo »

At the moment there are at least two ways I can think of to add some interactive feedback:

(1) Modify your shell script to create a log file in your home directory. For example, add the following at the end of the script:

Code: Select all

echo `date` >> ~/ups.sh.log
The command will save the date and time to a log file in the home directory. Note the quotes used in the date command are BACKQUOTES (symbol below the tilde key) and not SINGLE QUOTATION MARKS.

(2) If you have the libnotify-bin package installed you can use the notify-send command to alert you on-screen if the script has run its course. Just like in the previous method, you'll have to modify the script and add the following piece of code:

Code: Select all

notify-send -t 0 "Crontab Alert" "ups.sh finished running `date`"
The -t 0 switch tells notify-send to display a pop-up box at the center of the screen instead of a 10-second OSD at the upper right portion. Click OK or Cancel to dismiss the pop-up.

If you want to do a quick test, use a shorter delay -- say, 5 minutes -- instead of 35 in your cron table.

HTH.
o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
kaykav

Re: did cron job run

Post by kaykav »

Thank you, Pilosopong Tasyo, for that info. Actually I did think of adding a date cmd >to a file. I didn't know about the notify entry. I'll use it. Thank you again....
Locked

Return to “Beginner Questions”