I'm a newbie to setup a Cron jobs.
i have a prefix directory for my application python on /usr/local/lib/python2.7/dist-packages/prewikka and i already to new environment for my application python as PYTHONPATH=$prefix/lib/python2.7/dist-packages/prewikka:$prefix/bin/prewikka-httpd
i already a database MySQL manually :
mysql> DESC Prewikka_Crontab; +----------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+--------------+------+-----+---------+-------+ | id | varchar(255) | YES | | NULL | | | name | varchar(255) | NO | PRI | NULL | | | userid | varchar(255) | YES | | NULL | | | ext_type | varchar(255) | NO | | NULL | | | ext_id | varchar(255) | YES | | NULL | | | base | varchar(255) | NO | | NULL | | | runcnt | varchar(255) | YES | | NULL | | | schedule | varchar(255) | NO | | NULL | | | enabled | tinyint(11) | YES | | 1 | | | error | varchar(255) | YES | | NULL | | +----------+--------------+------+-----+---------+-------+ 10 rows in set (0.00 sec) if i launch prewikka-crontab, no output appears. when i launch prewikka-httpd, i always get the output :
... File "/usr/local/lib/python2.7/dist-packages/prewikka/history.py", line 102, in <module> crontab.schedule("search_history", N_("Search history deletion"), "0 * * * *", _regfunc=history._history_cron, enabled=True) File "/usr/local/lib/python2.7/dist-packages/prewikka/crontab.py", line 240, in schedule self._init_system_job(ext_type, name, schedule, enabled, _regfunc) File "/usr/local/lib/python2.7/dist-packages/prewikka/database.py", line 91, in inner ret = func(self, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/prewikka/crontab.py", line 154, in _init_system_job self.add(name, schedule, ext_type=ext_type, enabled=enabled) File "/usr/local/lib/python2.7/dist-packages/prewikka/crontab.py", line 219, in add return self.update(None, name=name, schedule=schedule, user=user, ext_type=ext_type, ext_id=ext_id, enabled=enabled) File "/usr/local/lib/python2.7/dist-packages/prewikka/crontab.py", line 209, in update return env.db.getLastInsertIdent() RuntimeError: could not retrieve last insert ID cause i don't have a event scheduler for my client to server side, how i can getting started it with Cron jobs?
Thanks in advance.
1 Answer
i figure it out on this link. a based of the Remove Heartbeats section on that link.
Step #1 make a .sh script :
#!/bin/sh set -e DB_TYPE="mysql" DB_HOST="localhost" DB_USER="xxxxxx" DB_PASS="xxxxxx" KEEP_INTERVAL="2 month" DATE=$(date -d "now - $KEEP_INTERVAL" +%Y-%m-%d) preludedb-admin delete heartbeat --criteria "heartbeat.create_time <= $DATE" "type=$DB_TYPE host=$DB_HOST user=$DB_USER pass=$DB_PASS" and make .sh as executable.
Step #2 make a cron job
sudo crontab -e add a event scheduler,
*/2 * * * * /usr/local/lib/python2.7/dist-packages/prewikka/crontab.py */2 * * * * /path/to/sripts/prewikka.sh restart using sudo init 6.
Hope this helps.