Create Scheduled Job in Alfresco

Sometimes we have requirements where we need to do certain processes or set of operations on a regular basis. It could be archival of contents or processing of existing documents in Alfresco repository to generate some reports, or another case is where you had a bunch of documents dropped by users on a shared drive and you want to upload them into Alfresco every day automatically to manage them easily. The possibilities are endless. Alfresco uses this kind of scheduled job for content archival and purging. Alfresco use spring’s cron job capabilities to meet up these requirements.

We are going to discuss how we could create our own scheduled job in alfresco. Steps to create it are as follow.

Step 1

Create custom-scheduled-job-context.xml where we define job detail and job trigger beans

<bean id="customJobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">

    <property name="jobClass">       
        <property name="jobDataAsMap">


                <entry key="abstractAuthenticationService">

                    <ref bean="authenticationService" />





    <bean id="customJobTrigger" class="org.alfresco.util.CronTriggerBean">

        <property name="jobDetail">

            <ref bean="customJobDetail"/>


        <property name="scheduler">

            <ref bean="schedulerFactory"/>


        <property name="cronExpression">

          <value>0 0 21 * * ?</value>



Place it under


Here we are creating custom Scheduled Job called customJobDetail and associating it with jobtrigger called customJobTrigger.

In the jobdatamap you can pass alfresco services which will be required by your job to access repository.

cronExpression value in customJobTrigger defines the time interval at which this job will be executed(provided alfresco is up and running J)

Step 2

Create job class CustomScheduledJob under package

Which extends java.lang.Object and

implements org.quartz.StatefulJob

We need to implement execute method and under that business logic will reside.

execute(org.quartz.JobExecutionContext context)

Package that class in jar and place the jar under


Restart the server and your scheduled job will be executed on defined time intervals. You can define the cron expression based on your requirements. Refer this guide to know more about cron expressions.

Field name


Allowed values

Allowed special characters


Minutes Yes 0-59 * / , –
Hours Yes 0-23 * / , –
Day of month Yes 1-31 * / , – ? L W
Month Yes 1-12 or JAN-DEC * / , –
Day of week Yes 0-6 or SUN-SAT * / , – ? L #
Year No 1970–2099 * / , – This field is not supported in standard/default implementations.

For debugging you need to add your job class in of alfresco. You will be able to see logs of your job run on interval you have mentioned in your context file.

Other References

Looking for quality Alfresco Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , , | Posted under Alfresco | RSS 2.0

Author Spotlight


I love opensource technologies working with those technologies from the time I have stepped in to the Software Industry. Alfresco CMS is my area of expertise. I have worked on various complex implementations which involved integration of Alfresco with other technologies, extensively worked with JBPM workflows and Webscripts.

Leave a Reply

Your email address will not be published. Required fields are marked *