简体   繁体   中英

Regarding cronjob execution time

I am having list of cron job functions.Each function run for certain period of time.Is there any way to find how long each cron function execute,Like time of start executing function and end time?

Expected output:

Cron tab start time: timestamp
cront tab end time: timestamp

Read crontab(5) . A cron job is just a shell command or script. That shell could, for example, use logger(1) mixed with date(1) and time(1) . See also time(7) . See also GNU bash documentation.

A cron job could also be a GUILE script, or a Python one. See execve(2) , fork(2) and other syscalls(2) which is called by crond

And cron is open source , so you are allowed to study its source code.... (eg of GNU mcron ). Or use strace(1) on it to understand its behavior.

Consider reading Advanced Linux Programming and see Linux From Scratch .

For example, I am running thru cron a backup script starting with

#!/bin/bash
cd $HOME
renice -n +2 -p $$
ionice -c Best-effort -n +5 -p $$
tm=$(date +"backup-home+%Y-%b-%d-%Hh%M")
logger --id=$$ -t backup-home start $tm
sync

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM