uvdesk / community-skeleton

UVdesk Opensource Community Helpdesk Project built for all to make a Full Ticketing Support System along with many more other features.
https://www.uvdesk.com
MIT License
8.53k stars 459 forks source link

Crontab #485

Closed Pekerche closed 2 years ago

Pekerche commented 2 years ago

Can someone help me? I believe it's a basic error, but I haven't been able to solve it yet. I'm not able to get CRONTAB to automatically update MAILBOX from uvdesk. The path to get to the uvdesk folder is: VAR/WWW/HTML/HELPDESK but I believe the path I put is wrong. Look how I left it:

/etc/crontab: system-wide crontab

Unlike any other crontab you don't have to run the `crontab'

command to install the new version when you edit this file

and files in /etc/cron.d. These files also have username fields,

that none of the other crontabs do.

SHELL=/bin/sh

You can also override PATH, by default, newer versions inherit it from the environment

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

Example of job definition:

.---------------- minute (0 - 59)

| .------------- hour (0 - 23)

| | .---------- day of month (1 - 31)

| | | .------- month (1 - 12) OR jan,feb,mar,apr ...

| | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat

| | | | |

* user-name command to be executed

17 root cd / && run-parts --report /etc/cron.hourly 25 6 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) /5 php /project_root_folder_path/bin/console uvdesk:refresh-mailbox your_mailbox_id_1 && php /project_root_folder_path/bin/console uvdesk:refresh-mailbox your_mailbox_id_2 && php /project_root_folder_path/bin/console uvdesk:refresh-mailbox teste123@gmail.com.br #

PeopleInside commented 2 years ago

Hi @Pekerche,

in my VPS I use a control panel that run under a specific user. The cron-job I set for UVdesk is not run as root but as user and is managed by my VPS control panel.

I discovered that if I run cron-job as root the prod folder inside UVdesk loose user permission and take root permission... as soon this happen I'm unable to clear cache and cron-job also stop to be working so new ticket email can be broken also.

I see you are following the UVdesk guide here: https://www.uvdesk.com/en/blog/how-to-refresh-mailbox-using-cron-job-in-uvdesk-opensource/

Did you tried to run the cronjob manually before set an automated cronjob? Before set the automated cronjob you may need be sure you have not configuration issues.

Usually when I setup an UVdesk instance I setup all settings than I send a test email to the email address that should make a ticket to be opened in UVdesk than I run the cron by SSH:

php /project_root_folder_path/bin/console uvdesk:refresh-mailbox your_mailbox_id

where you need replace your_mailbox_id with the desired email address that need check the ticket and you set in UVDesk.

Do you have some errors print if you run this command by SSH? If you open the UVdesk email settings, do you see your correct email address that should check tickets or do you see an address with @localdomain?

NOTE: your topic seems to be not a bug but a question. You can discuss questions in two different places without open a GitHub issue.

1. The official UVdesk community: https://forums.uvdesk.com/ 2. The discuss space on GitHub: https://github.com/uvdesk/community-skeleton/discussions

Pekerche commented 2 years ago

Yes, when I run via SSH it works perfectly. Here is the command line: root@Ticket:/var/www/html/helpdesk# php bin/console uvdesk:refresh-mailbox ticket@test.com.br

I enter the helpdesk folder through the terminal and type the command php bin/console uvdesk:refresh-mailbox ticket@test.com.br

Pekerche commented 2 years ago

But when I set it in linux crontab to run every 5 minutes, it won't. I've even configured it within the uvdesk crontab folder as well. I believe it's some path I didn't specify in the command to not run automatically.

PeopleInside commented 2 years ago

In the crontab you should have the full correct path for example:

php var/www/html/helpdesk/bin/console uvdesk:refresh-mailbox emailaddress@domain.ext >/dev/null 2>&1

NOTE: your topic seems to be not a bug but a question. You can discuss questions in two different places without open a GitHub issue.

1. The official UVdesk community: https://forums.uvdesk.com/ 2. The discuss space on GitHub: https://github.com/uvdesk/community-skeleton/discussions

Pekerche commented 2 years ago

it wasn't, I sent a test email and it didn't arrive. Here's the command line I put in crontab: /2 php var/www/html/helpdesk/bin/console uvdesk:refresh-mailbox ticket@domain.com.br

PeopleInside commented 2 years ago

Umh.. maybe the path is not fully correct. You can try do this: login in SSH without enter in any folder means you must be not in the UVdesk folder.

From here so from the folder you are when you enter in SSH as root you need test the SSH command to run the cron. For example: php var/www/html/helpdesk/bin/console uvdesk:refresh-mailbox email@domain.ext should give an error.

Usually for get the correct path I use SFTP, you have to enter to helpdesk/bin than copy the full address of the bin folder. I use BITVISE SSH client that has SFTP client too so I click on the address bar, I take the patch and I use in the command.

Maybe the path should be little bit different:

php html/helpdesk/bin/console uvdesk:refresh-mailbox email@domain.ext

NOTE: your topic seems to be not a bug but a question. You can discuss questions in two different places without open a GitHub issue.

1. The official UVdesk community: https://forums.uvdesk.com/ 2. The discuss space on GitHub: https://github.com/uvdesk/community-skeleton/discussions

Pekerche commented 2 years ago

It was not. I opened it directly in the folder and copied the path, when I did the command by ssh it was normal, but in crontab it wasn't. Correct command is:

/2 * php /var/www/html/helpdesk/bin/console uvdesk:refresh-mailbox ticket@domain.com.br

PeopleInside commented 2 years ago

If you want I can see if I can help with a free remote support. Please see this link for more info and for contact me on live chat https://helpdesk.peopleinside.it/it/blog/uv

NOTE: your topic seems to be not a bug but a question. You can discuss questions in two different places without open a GitHub issue.

1. The official UVdesk community: https://forums.uvdesk.com/ 2. The discuss space on GitHub: https://github.com/uvdesk/community-skeleton/discussions