Community forum

Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


alykhan
2008-02-25T23:20:45Z
I've been trying to figure out how to run a job randomly once in a 24 hour period. Is there a way to do this?

Thanks.

Sponsor
Forum information
ErikC
2008-02-26T09:03:43Z
You can do this with a perl script.

Create a script that uses a status file.
If the script runs for the 1st time it creates this file and it will enter a random date/time stamp in it when the script must run. Use a date format like CCYYMMDDHHMM.
This must be a date in the feature, and for today.
In Visualcron you need to run this job every minute.
If the script runs again it checkes this file and sees the date/time stamp. There are now some options:
1. current date/time is not the one in the status file and is less then the one in the status file -> exit program with errorlevel 1
2. current date/time is the one in the status file -> modify the date/time in the status file with a date/time for tomorrow -> exit program with errorlevel 0
3. current date/time is greater than the one in the status file -> you missed one running, do as step 2, so change the date and exit with a 0.

You can dismiss the CCYYMMDD and use only the HHMM because the job will run every minute.

In visualcron you add more tasks in this job after the perl script. The 1st task after the perl script will have a condition check on exit codes. Continou only if the exit of the previous task is a 0.

Hope this will help.
Uses Visualcron since 2006.
Support
2008-02-26T09:07:00Z
The current "run randomly" function does only base executions on random, not on previous results (if it has been run before or not). So, there is no way to force it to run a specified number of times during a time period.

We don't know the full need for this functionality, where we would place it and how it would work to be as generic as possible.

To solve single cases you can do it by scripting. For example, you could touch a file and if it has not been touched today you could return different and then read the result in the output using a Condition. Let us know if you need further help.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Support
2008-02-26T09:08:54Z
Thanks Erik, you were faster =d>
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top