Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by Shawn3
at 2024-07-25 09:52:48
Point:500 Replies:8 POST_ID:829106USER_ID:12005
Topic:
Unix Operating Systems;;
I would like cron to log start and end times for each job run. I know how to do this in DEBIAN but not red hat.
Author: Shawn3 replied at 2024-07-28 09:21:56
I will try that...but thought it was only for debian based distros...
Tried the crondargs, but it throws an error in RHEL. I think that param is for Debian based distros. Thanks though!
Tried the crondargs, but it throws an error in RHEL. I think that param is for Debian based distros. Thanks though!
Expert: Gerwin Jansen replied at 2024-07-28 08:55:28
You could try setting higher log level for cron in /etc/sysconfig/crond :
CRONDARGS= -L 2
and then restarting cron : sudo service cron restart
My preference is the solution you've chosen so you can easily keep track of all jobs in one place. And the cron log itself is not accessible for users.
CRONDARGS= -L 2
and then restarting cron : sudo service cron restart
My preference is the solution you've chosen so you can easily keep track of all jobs in one place. And the cron log itself is not accessible for users.
Author: Shawn3 replied at 2024-07-28 07:40:48
This will work, but I'm looking for system level logging for all cron jobs if possible.
Author: Shawn3 replied at 2024-07-28 07:38:13
Thanks Gerwin. I have hundreds of cron jobs. I think this is a great solution, but was hoping there was a system level logging setting that I could enable.
Accepted Solution
Expert: Gerwin Jansen replied at 2024-07-25 15:24:41
500 points GOOD
Simplest is to write wrapper commands (or script)
The wrapper logs start date/time with the cron script's name, calls the cron script and logs end date/time.
Easiest if you give every cron script it's own log file name.
For example:
The wrapper logs start date/time with the cron script's name, calls the cron script and logs end date/time.
Easiest if you give every cron script it's own log file name.
For example:
00 10 * * * echo "`date` Start of cron1" >> /home/user/cronjob1.log ; /home/user/cronjob1 ; echo "`date` End of cron1" >> /home/user/cronjob1.log 1:
Expert: duncanb7 replied at 2024-07-25 11:53:08
Why not make an example to the experts, other experts will come to solve issue
based your example ? otherwise, they don't know what you need
Duncan
based your example ? otherwise, they don't know what you need
Duncan
Author: Shawn3 replied at 2024-07-25 11:50:18
Thanks Duncan, but I know how to use cron. I need to know how to get a start and end time for each of the jobs. Currently, cron logs start time and thats it.
Thanks,
Shawn
Thanks,
Shawn
Expert: duncanb7 replied at 2024-07-25 11:07:11
For example,
*/10 * * 5,7,11 * root command1
0 9-18 * * 1-5 root command2
These lines will run command1 every ten minutes during May, July and November, and command2 once an hour during the working day (09:00 to 18:00) Monday to Friday.
Duncan
*/10 * * 5,7,11 * root command1
0 9-18 * * 1-5 root command2
These lines will run command1 every ten minutes during May, July and November, and command2 once an hour during the working day (09:00 to 18:00) Monday to Friday.
Duncan