Revigniter Cron

Here we document hoe to set up a cron job on revIgniter.

- https://www.digitalocean.com/community/tutorials/how-to-use-cron-to-automate-tasks-ubuntu-1804

# Tests - http://admin.fedwiki.org/view/welcome-visitors/rest.livecode.world/hello

# To Do 1. [x] Follow revIgniter test - userGuide 1. [x] Fix Permissions 1. Write Atopia Cron

# Run cron tab in directory For the cron job to work we must run the revIgniter shell script in the project folder of the revIgniter web site. - https://stackoverflow.com/questions/8899737/crontab-run-in-directory

# Example script

We create a controller `clock.lc` like this:

<?lc put "index,clock" into gControllerHandlers command clock start using stack (gRigA["APPPATH"] & "stacks/lib_Fedwiki.livecode") start using stack (gRigA["APPPATH"] & "stacks/lib_PageArray.livecodescript") start using stack (gRigA["APPPATH"] & "stacks/model_PageArray.livecodescript") start using stack (gRigA["APPPATH"] & "stacks/model_Transport.livecodescript") end clock command index # MAKE SURE THAT THE CONTROLLER IS ONLY ACCESSIBLE VIA COMMAND LINE if $_SERVER["PATH_TRANSLATED"] <> empty then put "This script can only be accessed via the command line." exit to top end if put the time into timeModel ["time"] transport_WriteModel "Test Model", timeModel put "Hello" && timeModel ["time"] & CR end index

# Login and edit crontab Login to the Transporter server and then edit your crontab:

crontab -e

Add the bash line to your crontab.

* * * * * cd /var/www/rest.livecode.world/ && /usr/lib/cgi-bin/livecode-community-server index.lc clock

This is: 1. Called evey minute `* * * * *` 1. Change directory (cd) to revIgniter project root 1. Add && to then... 1. Run path/to/livecode 1. Reference index fil (in project root) 1. Specify controller

# To debug Uncomment logging here - stackoverflow

nano /etc/rsyslog.d/50-default.conf

This is the line to uncomment:

cron.* /var/log/cron.log

If things go wrong you can restart `cron`:

service rsyslog restart service cron restart

Monitor the logs like this:

tail -f /var/log/cron.log