Job Schedular : Every Month 1 Day ; Delete all data from Collection;

Hi Velo Legends ,

I would like to clear/Delete my Database for Every Month First date.

I got Cron Expression for that is
“0 4 1 * *” => Is this correct ?

Before i try to test the Job Schedular that
Delete the same for Every minute

But am getting Error:
“jsonPayload”: {

“message”:“Failed to parse job configuration for site ‘winkle’: The interval is above 1 hours”
“jsonContent”: NULL

My Code

// /backend/jobs.config
{
“jobs” : [ // Define up to 20 different jobs
// Choose one of the options below to define the job execution interval:
{
// Option 1 - define execution interval using a cron expression
“functionLocation” : “/events.js” , // Relatively to Backend folder, started by slash
“functionName” : “deleteAll” ,
“description” : “Deleting All details In database” , // Optional
“executionConfig” : {
“cronExpression” : “* * * * *” // Interval for every minutes

            // Read about Cron expressions: [https://en.wikipedia.org/wiki/Cron#CRON_expression] 
        } 
    } 

] 

}

And In Events.js is:

import wixData from 'wix-data

// …

export function deleteAll () {

wixData . truncate ( "cache" )  // Here your collection/Database name should Come 
    . then (() => { 
        console . log ( "All items removed" ); 
    }) 
    . catch (( err ) => { 
        let  errorMsg  =  err ; 
    }); 

}


My Database/Collection Name is “Cache”

Anyone Help me out please ?
What am doing wrong ?


This may help to help me :slight_smile:

Can anyone please help me

It looks, OK, but have you tried the Wix tool here: Jobs Config | Velo by Wix

If I understand, you are trying to configure your cron job (as a test, before setting up the real crontab for monthly) to run every minute? If that’s the case, then Wix doesn’t support cron jobs that run more frequently than one hour.

you should use a cron expression like 0 0 1 * * for every hour.
you are using now 0 0 0 0 0 which is for every minute and not legal in wix/velo

Jobs Config Validator

Jobs Config builder and validator. Created special for Velo
https://shoonia.github.io/jobs.config/#builder