Thursday, July 26, 2018

How to Schedule Apex class to Run Instantly or Run After Some Duration from Developer Console

We create apex scheduler job which can be scheduled to run at specific time. If we want to run job instantly to either check the functionality or want to force start scheduled job then below code sample will help you.

Suppose you have scheduled apex class:

global class SK_JobsSchedulerHelper implements Schedulable {
global SK_JobsSchedulerHelper(){

}
       global void execute(SchedulableContext sc) {
//your business logic
}
}

Now if you want to run it instantly from developer console, then use below script:

SR_JobsSchedulerHelper sch = new SR_JobsSchedulerHelper();
sch.execute(null);

Now if you want to run this job after 5 minutes, then you can use below script:

SR_JobsSchedulerHelper sch = new SR_JobsSchedulerHelper();
Datetime dt = Datetime.now().addMinutes(5);  
String schCronExp = dt.format('s m H d M \'?\' yyyy');
Id schedId = System.Schedule(' scheduling this job at'+System.now().format(),schCronExp,sch);

Hope this help!!


6 comments:

  1. Coder Cyber Services is coming with premium solutions for lost crypto recovery on a single dedicated platform. New generation investors now have it easier thanks to cryptocurrency futures trading, but with so many unscrupulous and fraudulent brokers popping up, it's effortless to choose the wrong one when making investments. With the aid of this specialized tool from Coder Cyber Services,you can also gain the recovery of your lost cryptocurrency because their trade indications are so precise, you can utilize their technical signals to recover your lost cryptocurrency. Contact Coder Cyber Services immediately in order to get your stolen money back as soon as possible if you have been a victim of theft.
    Email: Codercyberservices@execs.com
    WhatsApp: +1 (403) 407-3407.

    Thanks.

    ReplyDelete
  2. Please, everyone should tread carefully with all these crypto brokers and crypto mining managers on social networks. I was duped with a whooping sum $ 640,000 of my investment capital by a broker I met via #Telegram. They kept on assuring me of my investment success growth while requesting for extra funds before a withdrawal request could be accepted and processed to access my investment, at the end of all my constant deposit, I lost all my money. All efforts trying to get them to return all I had invested with them was futile because they kept asking me for more money. I found myself in a very confusing state till recently when I was introduced to this group of Ethical Hackers. I wrote an email on ( cybergenie(@)cyberservices .co m) to them detailing my experience with that crypto broker, and they replied to me to provide proof of my investment with the said broker which I did, Lo and behold, before the end of the day, I got a notification from Trust Wallet of an incoming deposit, all that I lost was retrieved successfully..

    ReplyDelete
  3. Most Reliable and Recommended Crypto Recovery Expert, Captain WebGenesis.

    I was 99% Certain that I had been duped by a Crypto Investment company appearing as a Bakkt-based FX broker. I had lost 6.9Btc as a result of the company's website. As soon as possible, I had to hunt for help, and that's how I came across Captain WebGenesis, a certified Bitcoin recovery professional with specific cyber skills to recover lost money from scammers. His assistance and responses are satisfactory and professional. Captain WebGenesis succeeded in recovering 85% of my lost funds. I sincerely appreciate Him for his assistance, To anyone that has happened to be a victim too, you can file an email complaint through; Add (captainwebgenesis@hackermail.com).

    WhatsApp;; +1 (205)336-1020.
    More Info; captainwebgenesis.com

    ReplyDelete
  4. Tracking Down Lost Bitcoins and Other Cryptos:

    My experience of online scamming took seconds and cost me thousands. I was fooled by a YouTube video that convinced me that I could make a killing in Crypto, and the minute I clicked the link and deposited funds, I knew something was up, but it was too late. I worked with Captain WebGenesis, A certified and reliable Crypto Expert, it took a few days, and the Expert ensured I got almost all of the money back. It wouldn’t have been possible for me to meet up economically because I almost invested all my money but all thanks to this trustworthy Expert Captain WebGenesis with his genius effort to help me recover my already stolen currency. Please ensure also to consult Captain WebGenesis if you need such help:

    via email: Captainwebgenesis@hackermail.com or WhatsApp +1 205 3361020.

    ReplyDelete
  5. DO YOU NEED FINANCES? ARE YOU LOOKING FOR FINANCES? ARE YOU LOOKING FOR FINANCING TO ENLARGE YOUR BUSINESS?via email:bullsindia187@gmail.com

    ReplyDelete