Jump to content

Recommended Posts

Posted

Hello.

I want to host Telegram bot written in python 3 which uses long polling at Ricky server.

So, I uploaded files to my public_html.

I have written #!/usr/bin/python3.6 as the first line of my main file bot.py and have given 755 permission to it.

So, my question is how to run my bot for ever on Heliohost?

 

Cron jobs don't seem to be a solutiuon or I just don't understand how to use them for my case.

Any answers are appreciate.

Posted

In the cron job field put something like:

/usr/bin/python3.6 /home/denkorzh/path/to/script/telegram.py
If you don't want to get emails containing the output of the script you can tack this to the end:

/usr/bin/python3.6 /home/denkorzh/path/to/script/telegram.py >/dev/null 2>&1
That extra bit at the end redirects stdout and stderr to /dev/null which essentially means it gets deleted.
Posted

Keep in mind that we do monitor for cpu load and memory usage. We allow unlimited usage of both until you begin to slow down the other sites on your server or cause downtime. When that starts to happen we look at the log files of who is using the most and suspend them first. Running a process continually like this has a tendency to put you on the top of the list.

 

Another option that might cause less load is I can set up a remote cron for you. Basically what that means is you make a script that is visible through a browser like http://denkorzh.heliohost.org/cgi-bin/telegram.py that runs for a finite amount of time and then exits. Then I set it up so that script gets executed remotely as often as every 5 minutes.

 

Let us know if you need any help with anything.

 

How should I run cronjob once and for ever?

Just set the cron to run sometime in the next five minutes or whatever, and then wait until it starts. Once it's going delete the cron job.
Posted

That sounds good. My script doesn't seem to use much cpu or memory but if it occurs to do I would definitely limit its execution time.

By the way could you say is there python 3 installed at Ricky? And coul you install pytelegrambotapi python package for Ricky?

Thanks a lot.

Posted

Is there a particular version of python you're looking for?

 

Yes, it suits my project

 

And one more question - is there a way to terminate a script which was run with cron job?

Posted

You would have to ask an admin or run another cron. Actually that is a common thing for people to do is leave the cronjob set up to run once or twice a day, and when the new cron fires the script looks for previous versions of itself and kills them prior to running the main loop. This is especially useful if there is a bug in the code that causes it to hang for some reason. The next cron will stop the broken script and start a new version. Here is how I would stop the script with a cron:

killall -u denkorzh >/dev/null 2>&1
  • Like 1
Posted

Python 3.6.1 has been installed on Ricky at /usr/bin/python3.6 just like Tommy.

 

pyTelegramBotAPI has been installed on python 3.6.1 on Ricky.

 

Just make sure you don't violate the spam line in our terms of service:

Your site will not email, personal message, instant message, or communicate any kind of "spam," or unsolicited bulk advertising of any kind.

ToS: http://wiki.helionet.org/Terms

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...