qianhe If you're just running a cron job on a local server, you don't need an API key. First off, I'll assume you've got your mail details all set up correctly to pull tickets in from your mailbox. You need the username your web server runs as, usually www-data or apache .
SSH into your server and type the following (note you need to be using an account with sudo access)
sudo crontab -e -u www-data
(replace www-data in the example above with the username your web server runs as)
In the text editor that comes up, enter the following:
*/2 * * * * php /var/www/html/api/cron.php > /dev/null 2>&1
Then save and exit, and in osTicket Admin -> Emails -> Settings ensure Email fetching is enabled, but fetch on auto-cron is not.
This will poll your mailbox every 2 minutes (change the /2 to another number if you want to change this) and the > /dev/null 2>&1 part at the end ensures you don't get an email every time the cron job runs.