Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New install : Scheduler not working #4592

Open
patrice-go-dsi opened this issue Feb 16, 2025 · 11 comments
Open

New install : Scheduler not working #4592

patrice-go-dsi opened this issue Feb 16, 2025 · 11 comments
Labels

Comments

@patrice-go-dsi
Copy link

  • Brand new installation : 3.1.3.13
  • Linux 4.18.0-513.24.1.lve.2.el8.x86_64
  • MariaDB Ver 15.1 Distrib 10.6.21-MariaDB
  • Apache2
  • PHP 8.1

Everything seems to be OK during installation.

Scheduled tasks seem to get stuck.
If I create a new user, nothing happens. The account remains inactive.

I have to run manually :
php scripts/background_tasks___userKeysCreation.php

User is activated.

And then, to receive the mail :
php scripts/background_tasks___sending_emails.php

The user receives his credential by email.

If i run manually :
php /home/xxxxxxx/teampass.xxxxxxxxxx/sources/scheduler.php

Nothing happens.

if i run manually :
php /home/xxxxxxx/teampass.xxxxxxxxxx/sources/scheduler.php >> /var/logs/cron-tp.log

I have :

Status: 500 Internal Server Error
X-Powered-By: PHP/8.1.31
Content-type: text/html; charset=utf-8
Cache-Control: no-cache, must-revalidate
Set-Cookie: PHPSESSID=g7ghu5mbm6lv3krn6rdmciq4eg; expires=Mon, 17-Feb-2025 16:30:02 GMT; Max-Age=86400; path=/; HttpOnly; SameSite=Lax

Image

Any ideas ?
Tx,
Patrice

@patrice-go-dsi
Copy link
Author

patrice-go-dsi commented Feb 17, 2025

Every time I run sources/scheduler.php I get this error :

[17-Feb-2025 11:31:02 Europe/Paris] PHP Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null givenin /home/xxxx/teampass.xxxx/scripts/background_tasks___items_handler.php:134 Stack trace: #0 /home/xxxx/teampass.xxxx/scripts/background_tasks___items_handler.php(134): in_array() #1 {main} thrown in /home/xxxx/teampass.xxxx/scripts/background_tasks___items_handler.php on line 134

@patrice-go-dsi
Copy link
Author

This problem makes teampass unusable.
I'm going to look at another solution for password management.
These chronic instability of teampass are damage...

V2 was less pretty but significantly more stable.

@gtechgroupit
Copy link

Same Bug for me

@patrice-go-dsi
Copy link
Author

has anyone found a solution for this problem? I still can't create my users...

@patrice-go-dsi
Copy link
Author

Scheduler gets stuck on :
bopaxxxx 1534128 1 0 12:25 ? 00:00:00 /opt/alt/php81/usr/bin/php-cgi /home/bopaxxxx/teampass.xxxxx.xxxx/sources/../scripts/background_tasks___userKeysCreation.php bopaxxxx 1534317 1534128 0 12:25 ? 00:00:00 [php-cgi] <defunct> bopaxxxxx 1534318 1534128 0 12:25 ? 00:00:00 [php-cgi] <defunct> bopaxxxxx 1534319 1534128 0 12:25 ? 00:00:00 [php-cgi] <defunct>

@dumitru2002
Copy link

IDK if its your case, but try this.
#4202 (comment)

@nilsteampassnet
Copy link
Owner

@patrice-go-dsi
Can you run php -i | grep register_argc_argv?
Indeed register_argc_argv should be set to on
I will add a check on this

@patrice-go-dsi
Copy link
Author

patrice-go-dsi commented Feb 22, 2025

yes, it is set to on :

$ php -i | grep register_argc_argv
register_argc_argv => On => On

And :

$ php -v
PHP 8.1.31 (cli) (built: Nov 20 2024 11:27:24) (NTS)

@nilsteampassnet
Copy link
Owner

nilsteampassnet commented Feb 23, 2025

@patrice-go-dsi
Surprising ... how is it possible to habe $argv equal to null if enabled and launched using CLI ????

Can you please do the next fix that I will commit later?
Open file scripts/background_tasks__items_handler.php
Find

// The main process run new iteratives process for each subtask
if (!in_array('--child', $argv)) {

and replace by

// Check if $argv is defined and is an array
if (!isset($argv) || !is_array($argv)) {
    $argv = [];
}

// The main process run new iteratives process for each subtask
if (!in_array('--child', $argv)) {

This will remove any error related to $argv = null

@phcmc1978
Copy link

phcmc1978 commented Feb 26, 2025

Similar problem, but different error, here...

Image

Image

Brand new installation : 3.1.3.14
Ubuntu 22.4.3 LTS
v 15.1 Distrib 10.6.18-MariaDB
Apache2
PHP 8.1
Everything seems to be OK during installation.

Scheduled tasks seem to get stuck.
If I create a new user, nothing happens. The account remains inactive.

sudo php /.../sources/scheduler.php
does nothing but returns

sudo php scripts/background_tasks___userKeysCreation.php
stay frozen

Any ideas ?

@gustavoara
Copy link

gustavoara commented Feb 27, 2025

Hey @patrice-go-dsi , I recently encountered the same issue with scheduled tasks not running automatically in TeamPass, and I managed to fix it.

Image

The problem seems to be that some PHP functions used in the scheduler are disabled by the hosting environment (e.g., exec(), shell_exec(), passthru(), etc.). Apache/PHP configurations often restrict these functions for security reasons, which prevents the scheduler from properly executing background tasks.

The job.php file (located in vendor/peppeocchi/php-cron-scheduler/src/GO/) contains a line that executes the scheduled tasks using exec(). If your hosting environment blocks this function, the scheduler fails silently.

Instead of:

exec($compiled,` $this->output, $this->returnCode);

Try replacing it with:

$descriptorspec = [
    0 => ["pipe", "r"],
    1 => ["pipe", "w"],
    2 => ["pipe", "w"],
];

$process = proc_open($compiled, $descriptorspec, $pipes);

if (is_resource($process)) {
    $this->output = stream_get_contents($pipes[1]);
    fclose($pipes[1]);
    $this->returnCode = proc_close($process);
}

This change bypasses the restriction by using proc_open() instead of exec(), allowing the tasks to execute properly.

Edit the job.php file (line 395 in the original version).
Replace the exec($compiled, $this->output, $this->returnCode); line with the code above.
Save the file and try running php sources/scheduler.php again.
Check if tasks now execute automatically.

I applied this fix and now all my scheduled tasks (like new_item, send_email, etc.) are processing correctly without manual execution. Let me know if this works for you! 🚀😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants