Our experts are always on hand to help answer your questions, get you started, and grow your presence online. You can email us any time
Enable cron for your hidden service
A Cron service refers to a task scheduler found in Unix-like operating systems. It is utilized by users who establish and upkeep software environments to schedule tasks, referred to as cron jobs, to execute on a regular basis at predetermined times, dates, or intervals.
This guide will illustrate how you schedule a command to run every minute.
You can create cron.php in your www folder, and the PHP script is as below:
<?php $url = 'https://www.blockonomics.co/api/price?currency=USD'; $proxy = 'proxy:9050'; $timeout = 5; $ch = curl_init(); if($ch === false) die('Failed to create curl object'); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_PROXY, $proxy); curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME); $content = curl_exec($ch); curl_close($ch); file_put_contents('/var/www/html/price.txt', time() . '.' . $content);
If you set the cron schedule successfully, you will see the file "/var/www/html/price.txt" is changed every minute. And the content will be as follow:
1711723205.{"price": 69666.4}
1711723264.{"price": 69666.4}
On our Customer Portal, click your Onion Service, and navigate to the "Cron" tab.
Scroll to the "Cron Credential" section, you will see your credential to login your cron service.
Scroll to the "Cron Guideline" section, you will see the guideline to setup your cron service.
Open Tor Browser, enter your Cron service URL, and enter your credential.
You will see your Cron service landing page.
Enter the environment variables, and click "Save to crontab"
SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
Then, click "New" to create a new Cron job
Type the command you want to run regularly.
/usr/local/bin/php /var/www/html/cron.php
Click "Set" button to set your cron job schedule. By default, the cron schedule is "* * * * *". It means that the command is scheduled to run every minute. Then click "Save" button to continue.
Click "Save to crontab" to save your change.
Our experts are always on hand to help answer your questions, get you started, and grow your presence online. You can email us any time