Format cron log
This commit is contained in:
parent
970be4c29c
commit
1c2d4cedee
|
@ -5,18 +5,16 @@ import { format } from 'date-fns'
|
|||
|
||||
console.log('Scheduling Tasks...')
|
||||
|
||||
function logMsg(msg) {
|
||||
console.log(`[${format(new Date(), 'HH:MM')}] cron: ${msg}`)
|
||||
}
|
||||
|
||||
cron.schedule(
|
||||
'*/5 * * * *',
|
||||
async () => {
|
||||
console.log(
|
||||
'[cron exec] updateDBWithOnlineDevices started at ' +
|
||||
format(new Date(), "d 'de' MMMM 'de' yyyy HH:MM")
|
||||
)
|
||||
logMsg('updateDBWithOnlineDevices started.')
|
||||
await updateDBWithOnlineDevices()
|
||||
console.log(
|
||||
'[cron exec] updateDBWithOnlineDevices finished at ' +
|
||||
format(new Date(), "d 'de' MMMM 'de' yyyy HH:MM")
|
||||
)
|
||||
logMsg('updateDBWithOnlineDevices finished.')
|
||||
},
|
||||
{}
|
||||
)
|
||||
|
@ -24,13 +22,9 @@ cron.schedule(
|
|||
cron.schedule(
|
||||
'0 0 0 * * *',
|
||||
async () => {
|
||||
console.log(
|
||||
'cron exec: User.importAllUsers started at ' + new Date().toTimeString()
|
||||
)
|
||||
logMsg('User.importAllUsers started')
|
||||
await User.importAllUsers()
|
||||
console.log(
|
||||
'cron exec: User.importAllUsers finished at ' + new Date().toTimeString()
|
||||
)
|
||||
logMsg('User.importAllUsers finished')
|
||||
},
|
||||
{}
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user