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...')
|
console.log('Scheduling Tasks...')
|
||||||
|
|
||||||
|
function logMsg(msg) {
|
||||||
|
console.log(`[${format(new Date(), 'HH:MM')}] cron: ${msg}`)
|
||||||
|
}
|
||||||
|
|
||||||
cron.schedule(
|
cron.schedule(
|
||||||
'*/5 * * * *',
|
'*/5 * * * *',
|
||||||
async () => {
|
async () => {
|
||||||
console.log(
|
logMsg('updateDBWithOnlineDevices started.')
|
||||||
'[cron exec] updateDBWithOnlineDevices started at ' +
|
|
||||||
format(new Date(), "d 'de' MMMM 'de' yyyy HH:MM")
|
|
||||||
)
|
|
||||||
await updateDBWithOnlineDevices()
|
await updateDBWithOnlineDevices()
|
||||||
console.log(
|
logMsg('updateDBWithOnlineDevices finished.')
|
||||||
'[cron exec] updateDBWithOnlineDevices finished at ' +
|
|
||||||
format(new Date(), "d 'de' MMMM 'de' yyyy HH:MM")
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
{}
|
{}
|
||||||
)
|
)
|
||||||
|
@ -24,13 +22,9 @@ cron.schedule(
|
||||||
cron.schedule(
|
cron.schedule(
|
||||||
'0 0 0 * * *',
|
'0 0 0 * * *',
|
||||||
async () => {
|
async () => {
|
||||||
console.log(
|
logMsg('User.importAllUsers started')
|
||||||
'cron exec: User.importAllUsers started at ' + new Date().toTimeString()
|
|
||||||
)
|
|
||||||
await User.importAllUsers()
|
await User.importAllUsers()
|
||||||
console.log(
|
logMsg('User.importAllUsers finished')
|
||||||
'cron exec: User.importAllUsers finished at ' + new Date().toTimeString()
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
{}
|
{}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user