Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#826066
I saw the following link:
https://www.pmusers.com/index.php/Send_ ... is_overdue
For sending an email when a task is overdue, you mentioned that:
Create a separate process that loops endlessly to execute a script forever:
If I want to write a trigger at the same process (not a separate process), how can I do that? I want to be sent an overdue email after the same task which is situated in the same process. (not another process).
When a task is overdue, a trigger should be fired after that to inform the responsible and his/her manager ( in the same process)
#826067
You can can create a looping script task which is parallel to the task which you are checking to be overdue like this:
ProcessToExecuteInSameProcess.png
ProcessToExecuteInSameProcess.png (31.66 KiB) Viewed 12160 times
Your trigger will have to set a variable that can be checked by conditions in the exclusive gateway to decide whether to keep looping or continue to "Task 3".

Tip: You should set your process's calendar to cover 24 hours per day, 7 days per week, so that it the intermediate event timer event starts counting the time immediately.

However, I don't understand why you don't want to use a separate process. It is much more efficient to let one case in another process send out all the emails for all the overdue cases at the same time. If you have a lot of cases, it will take a long time to execute timereventcron.php if you are starting a new intermediate timer for every case. Another thing to keep in mind is that the above process will force the case to pause after the user completes the "Task to check if overdue". Only when the timereventcron.php executes will the case continue to "Task 3". If you use a separate process, there will be no pause in the case between "Task to check if overdue" and "Task 3."
#826077
Thanks Amos,
You are right, it is better to run in a separate process, however I have some problems with intermediate timer event.
First of all, does it work in community edition? if yes, how can I use it in windows?
Is there any alternative way not to use intermediate timer event?
#826088
saraaa wrote: Wed Aug 21, 2019 12:13 pm Thanks Amos,
You are right, it is better to run in a separate process, however I have some problems with intermediate timer event.
First of all, does it work in community edition? if yes, how can I use it in windows?
Is there any alternative way not to use intermediate timer event?
Intermediate timer events are the only easy way to do this, if you don't want to create your own external scrip.

I have never been able to get Scheduled Tasks to work in Windows inside a virtual machine, so I have never been able to test intermediate timer events in Windows, because timereventcron.php needs to be executed by a Windows Scheduled Task. I don't have a normal installation of Windows (not in a virtual machine), so I can't test it.

You can try installing cygwin and cron in Windows:
http://tinypig.pbworks.com/f/cygwin-cron.pdf

The other solution is switch to Linux, which I highly recommend if you are going to run ProcessMaker in production.
#826180
Thanks Amos,
I'm trying to find a new solution like writing PHP code instead of intermediate timer events.
I used this code at the end of the same trigger. Actually, I called a new function{function overdue()} and previous code has been located in this function. Then, I wrote the following code:
Code: Select all
while(true) 
//do something (the same code that you published in pmusers.com)
overdue();
sleep(28800)
}

I know the code is nonsense!
Do you have any idea?
#826186
Waiting 8 hours in a PHP script? That is a very bad idea.

Can you schedule some other program to execute as a Scheduled Task in Windows to verify whether Scheduled Tasks work or not? Once you have verified that, then post the exact steps that you took to schedule the execution of timereventcron.php.

The other option is to switch to Linux, which is the best solution.
#826209
Thanks Amos,
First of all, I used your process (https://www.pmusers.com/index.php/Send_ ... is_overdue) for sending an email when a task is overdue. (that’s OK. The only problem is that intermediate timer event does not work)
Then, I wrote the following code in Command Prompt:
Code: Select all
SCHTASKS /Create /sc MINUTE /mo 2 /tn "ProcessMaker Cron every 2 minutes" /TR "C:\wamp\php\php.exe -f D:\processmaker\apps\processmaker\htdocs\workflow\engine\bin \cron.php 
I don’t understand what is the functionality of "C:\wamp\php\php.exe" in above command? Anyway, my wamp has been located in Drive D.
When I entered the above command line, the scheduled task “ProcessMAker Cron every 2 min” successfully created.
Then, I ran your process, PM did not send email. Also, there is no log in Admin/Logs/Cron!
Another point is that there is no location in task scheduler for task “ProcessMAker Cron every 2 min”
I think, Windows run its trigger regularly, but it cannot get the location of Cron.php. It shows empty in the location segment.
What is the problem? Do you know?
#826245
saraaa wrote: Wed Aug 28, 2019 12:47 pm Then, I wrote the following code in Command Prompt:
Code: Select all
SCHTASKS /Create /sc MINUTE /mo 2 /tn "ProcessMaker Cron every 2 minutes" /TR "C:\wamp\php\php.exe -f D:\processmaker\apps\processmaker\htdocs\workflow\engine\bin \cron.php 
I don’t understand what is the functionality of "C:\wamp\php\php.exe" in above command? Anyway, my wamp has been
C:\wamp\php\php.exe is the path to where you have PHP installed so that you can use PHP to execute the timereventcron.php file. You need to change it to match your system.

You don't have the closing quotation mark at the end of your command and you have a space in the path that shouldn't be there. Also you need to execute both the timereventcron.php and cron.php scripts.

First, you need to delete that scheduled task because it is bad:
schtasks /delete /tn "ProcessMaker Cron every 2 minutes"

Then, you need to test these commands to make sure that they works from the command line of your server:
C:\wamp\php\php.exe D:\processmaker\apps\processmaker\htdocs\workflow\engine\bin\cron.php -f
C:\wamp\php\php.exe D:\processmaker\apps\processmaker\htdocs\workflow\engine\bin\timereventcron.php -f

(Add the -f option to force it to execute.)

Does it work when executing manually? If so, then you know that the commands are good. If you don't know, then post the output of the commands.

Now you need to schedule the commands to not execute at the same time. You shouldn't be executing every 2 minutes! (Did you read the documentation where it explains that the command has to finish, so you should leave 5 minutes for it to complete? And remember to add the -f to the end.
#826290
Thank you Amos,
I tested these commands to make sure that they work from the command line of my server:
C:\wamp\php\php.exe D:\processmaker\apps\processmaker\htdocs\workflow\engine\bin\cron.php -f
C:\wamp\php\php.exe D:\processmaker\apps\processmaker\htdocs\workflow\engine\bin\timereventcron.php -f

I see this after running above code:
'php' is not recognized as an internal or external command,operable program or batch file
Then, I also wrote this code:
SCHTASKS /Create /sc MINUTE /mo 2 /tn "ProcessMaker Cron every 2 minutes" /TR "C:\wamp\php\php.exe -f D:\processmaker\apps\processmaker\htdocs\workflow\engine\bin \cron.php"
I see this error every 2 minutes:
Deprecated: Methods with the same name as their class will not be constractors in a future version of PHP;
pakaYAMLNode has a deprecated constructor in ...\pakaYaml.class.php on line 54
'php' is not recognized as an internal or external command,operable program or batch file
#826295
You need to change the
saraaa wrote:I tested these commands to make sure that they work from the command line of my server:
C:\wamp\php\php.exe D:\processmaker\apps\processmaker\htdocs\workflow\engine\bin\cron.php -f
C:\wamp\php\php.exe D:\processmaker\apps\processmaker\htdocs\workflow\engine\bin\timereventcron.php -f
Does it work this way?
C:\wamp\php\php.exe -f D:\processmaker\apps\processmaker\htdocs\workflow\engine\bin\cron.php -f


saraaa wrote:I see this error every 2 minutes:
In your php.ini file, you need to have the following settings to avoid errors:
Code: Select all
file_uploads = On 
short_open_tag = On 
memory_limit = 512M 
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT 
display_errors = Off 
post_max_size = 24M 
upload_max_filesize = 24M
#826319
Thank you Amos,
Again when I test these commands manually, I see this message(according to the image below):
C:\wamp\php\php.exe –f D:\processmaker\apps\processmaker\htdocs\workflow\engine\bin\cron.php -f
C:\wamp\php\php.exe –f D:\processmaker\apps\processmaker\htdocs\workflow\engine\bin\timereventcron.php -f
Attachments
cron.png
cron.png (29.68 KiB) Viewed 11865 times
#826328
I just tried it in Windows. You need to add C:\wamp\php to your system's Path variable.

Then, close the terminal and open a new terminal for the new Path to take effect.

Then, I got it to work this way:
php D:\processmaker\apps\processmaker\htdocs\workflow\engine\bin\cron.php -f

PS: For some reason php -f D:\processmaker\apps\processmaker\htdocs\workflow\engine\bin\cron.php -f doesn't work in Windows.

A 1xbet clone script is a pre-designed software so[…]

4rabet clone script is enabling entrepreneurs to e[…]

Parimatch clone script is enabling entrepreneurs t[…]

In the world of cryptocurrency, a wallet is an app[…]