Pular para o conteúdo principal
Base de Conhecimento da FocusVision

Cronwrap

  Requires Decipher Cloud

You can now go to http://v2.decipherinc.com/apps/automations/ to check the status page of automated background jobs which ran on the previous 7 days including today.

1:  Setting up a config file

config files are located at v2/data/cronwrap.d/ and this is where you will be specifying information about each job which will run on cron. cronwrap script will run jobs based on what is specified in a config file. This is an example of a job in a config file.

#Group name
[foo]
comments = foo project 

#Job name
[[foo-task1]]

name = job for foo-task1 

#Script or command you need to run
command = python2.5 ~v2/foo/foo09001/data-export.py

#If the job doesn't finish on given maxtime, the process will get killed
maxtime = 1200 #seconds

#Recipients who will get an email ONLY if job fails
fail_only_recipients = foo-fail@decipherinc.com bar-fail@decipherinc.com
#Recipients who will get an email all the time
all_recipients = foo@decipherinc.com bar@decipherinc.com

#Job will fail if these strings are matched in stdout. They can be regular expressions
error_list = "Traceback Error", "failed"

#Job will fail if these strings are NOT found in stdout. They can be regular expressions
success_list = "[0-9]* respondents completed", "process completed"


#Job name
[[foo-task2]]

name = job for foo-task1 

#Script or command you need to run
command = bash ~v2/foo/foo09001/foo-send

#If the job doesn't finish on given maxtime, the process will get killed
maxtime = 60 #seconds

#Recipients who will get an email ONLY if job fails
fail_only_recipients = foo-fail@decipherinc.com bar-fail@decipherinc.com
#Recipients who will get an email all the time
all_recipients = foo@decipherinc.com bar@decipherinc.com

#Job will fail if these strings are matched in stdout. They can be regular expressions
error_list = "Traceback Error", "failed"

#Job will fail if these strings are NOT found in stdout. They can be regular expressions
success_list = "[0-9]* respondents completed", "process completed"

NOTE: Ad-hoc projects are included in 01projects.conf.

1. It is important to have a fair idea of how long the process would take to run when specifying the maxtime.

2. After creating a job/group, run conwrap -c to make sure there are no errors in the config file. It is important to run it every time you make a change or else other jobs might fail.

2:  Running cronwrap

cronwrap --group=XXX --task-name=XXX
Options:
  -d, --no-update-database  Do NOT update database which shows status of the
                            task in status page of automated background jobs
  -c, --check-config        Check for errors in config file
  -g, --group=              Group which the task belongs to (e.g. 'ebay')
  -n, --task-name=          Task name of the job (e.g 'eby_email_send')
      --version             
      --help                Display this help and exit.

1. Check for errors in config files. You must run this every time you make a change/addition in a config file in v2/data/cronwrap.d/.

~/v2$ cronwrap -c #check for errors in config files

2. Manually running a job

~/v2$ cronwrap --group=foo --task-name=foo-task1 #runs the job and updates the database
~/v2$ cronwrap --group=foo --task-name=foo-task1 -no-update-database #runs the job and without updating the database(not recommended unless testing)

3. Setting up a cronjob with cronwrap.

# bug NNNN: foo group of jobs
00 07 * * *     cronwrap -g foo -n foo-task1
10 12 * * mon   cronwrap --group=foo --task-name=foo-task2