这是indexloc提供的服务,不要输入任何密码
Skip to content

How to use Scheduled Cron Tasks #4695

@OpticNectar

Description

@OpticNectar

Can someone please clarify how the Scheduled Cron Tasks work? I'm trying to run a rails rake task via the cron, but it doesn't run. The examples don't really show if you're supposed to use dokku in the command or how exactly that works. I also couldn't find any examples online.

My app.json

{
    "cron": [{
        "command": "rake my_task:import",
        "schedule": "@daily"
    }]
}

Environment Information

-----> uname: Linux app-name 5.4.0-74-generic #83-Ubuntu SMP Sat May 8 02:35:39 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
-----> memory: 
                     total        used        free      shared  buff/cache   available
       Mem:           1987        1731          75           6         180          84
       Swap:          2047         943        1104
-----> docker version: 
       Client: Docker Engine - Community
        Version:           20.10.3
        API version:       1.41
        Go version:        go1.13.15
        Git commit:        48d30b5
        Built:             Fri Jan 29 14:33:21 2021
        OS/Arch:           linux/amd64
        Context:           default
        Experimental:      true
       
       Server: Docker Engine - Community
        Engine:
         Version:          20.10.3
         API version:      1.41 (minimum version 1.12)
         Go version:       go1.13.15
         Git commit:       46229ca
         Built:            Fri Jan 29 14:31:32 2021
         OS/Arch:          linux/amd64
         Experimental:     false
        containerd:
         Version:          1.4.3
         GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b
        runc:
         Version:          1.0.0-rc92
         GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
        docker-init:
         Version:          0.19.0
         GitCommit:        de40ad0
-----> docker daemon info: 
       Client:
        Context:    default
        Debug Mode: true
        Plugins:
         app: Docker App (Docker Inc., v0.9.1-beta3)
         buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
       
       Server:
        Containers: 7
         Running: 6
         Paused: 0
         Stopped: 1
        Images: 8
        Server Version: 20.10.3
        Storage Driver: overlay2
         Backing Filesystem: extfs
         Supports d_type: true
         Native Overlay Diff: true
        Logging Driver: json-file
        Cgroup Driver: cgroupfs
        Cgroup Version: 1
        Plugins:
         Volume: local
         Network: bridge host ipvlan macvlan null overlay
         Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
        Swarm: inactive
        Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
        Default Runtime: runc
        Init Binary: docker-init
        containerd version: 269548fa27e0089a8b8278fc4fc781d7f65a939b
        runc version: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
        init version: de40ad0
        Security Options:
         apparmor
         seccomp
          Profile: default
        Kernel Version: 5.4.0-74-generic
        Operating System: Ubuntu 20.04.2 LTS
        OSType: linux
        Architecture: x86_64
        CPUs: 2
WARNING: No swap limit support
WARNING: No blkio weight support
WARNING: No blkio weight_device support
        Total Memory: 1.941GiB
        Name: app-name
        ID: OC32:33FN:FKGV:J7YY:J4MZ:6BDO:2VPU:WDPI:Z43Z:D2H5:PJVL:57C3
        Docker Root Dir: /var/lib/docker
        Debug Mode: false
        Registry: https://index.docker.io/v1/
        Labels:
        Experimental: false
        Insecure Registries:
         127.0.0.0/8
        Live Restore Enabled: false
       
-----> git version: git version 2.25.1
-----> sigil version: 0.6.0
-----> herokuish version: 
       herokuish: 0.5.25
       buildpacks:
         heroku-buildpack-multi     v1.0.0
         heroku-buildpack-ruby      v223
         heroku-buildpack-nodejs    v183
         heroku-buildpack-clojure   v86
         heroku-buildpack-python    v188
         heroku-buildpack-java      v69
         heroku-buildpack-gradle    v34
         heroku-buildpack-scala     v88
         heroku-buildpack-play      v26
         heroku-buildpack-php       v189
         heroku-buildpack-go        v151
         buildpack-nginx            v14
         buildpack-null             v3
-----> dokku version: dokku version 0.23.2
-----> plugn version: plugn: 0.6.1
-----> dokku plugins: 
         00_dokku-standard    0.23.2 enabled    dokku core standard plugin
         20_events            0.23.2 enabled    dokku core events logging plugin
         app-json             0.23.2 enabled    dokku core app-json plugin
         apps                 0.23.2 enabled    dokku core apps plugin
         builder-cnb          0.23.2 enabled    dokku core builder-cnb plugin
         builder-dockerfile   0.23.2 enabled    dokku core builder-dockerfile plugin
         builder-herokuish    0.23.2 enabled    dokku core builder-herokuish plugin
         buildpacks           0.23.2 enabled    dokku core buildpacks plugin
         certs                0.23.2 enabled    dokku core certificate management plugin
         checks               0.23.2 enabled    dokku core checks plugin
         common               0.23.2 enabled    dokku core common plugin
         config               0.23.2 enabled    dokku core config plugin
         cron                 0.23.2 enabled    dokku core cron plugin
         docker-options       0.23.2 enabled    dokku core docker-options plugin
         domains              0.23.2 enabled    dokku core domains plugin
         enter                0.23.2 enabled    dokku core enter plugin
         git                  0.23.2 enabled    dokku core git plugin
         logs                 0.23.2 enabled    dokku core logs plugin
         network              0.23.2 enabled    dokku core network plugin
         nginx-vhosts         0.23.2 enabled    dokku core nginx-vhosts plugin
         plugin               0.23.2 enabled    dokku core plugin plugin
         postgres             1.11.6 enabled    dokku postgres service plugin
         proxy                0.23.2 enabled    dokku core proxy plugin
         ps                   0.23.2 enabled    dokku core ps plugin
         redis                1.13.0 enabled    dokku redis service plugin
         repo                 0.23.2 enabled    dokku core repo plugin
         resource             0.23.2 enabled    dokku core resource plugin
         scheduler-docker-local 0.23.2 enabled    dokku core scheduler-docker-local plugin
         shell                0.23.2 enabled    dokku core shell plugin
         ssh-keys             0.23.2 enabled    dokku core ssh-keys plugin
         storage              0.23.2 enabled    dokku core storage plugin
         tags                 0.23.2 enabled    dokku core tags plugin
         tar                  0.23.2 enabled    dokku core tar plugin
         trace                0.23.2 enabled    dokku core trace plugin
=====> app-name app information
       App deploy source:             
       App dir:                       /home/dokku/app-name
       App locked:                    false
=====> app-name buildpacks information
       Buildpacks computed stack:     gliderlabs/herokuish:latest
       Buildpacks global stack:       
       Buildpacks list:               https://github.com/OpticNectar/heroku-buildpack-nodejs.git,https://github.com/heroku/heroku-buildpack-ruby.git
       Buildpacks stack:              
OU = Domain Control Validated, CN = primestoragegroup.app
error 20 at 0 depth lookup: unable to get local issuer certificate
=====> app-name ssl information
       Ssl dir:                       /home/dokku/app-name/tls
       Ssl enabled:                   true                     
       Ssl hostnames:                 primestoragegroup.app www.primestoragegroup.app
       Ssl expires at:                May 11 14:20:47 2022 GMT 
       Ssl issuer:                    C = US, ST = Arizona, L = Scottsdale, O = GoDaddy.com, Inc., OU = http://certs.godaddy.com/repository/, CN = Go Daddy Secure Certificate Authority - G2
       Ssl starts at:                 Apr  9 14:20:47 2021 GMT 
       Ssl subject:                   subject=OU = Domain Control Validated, CN = primestoragegroup.app
       Ssl verified:                  self signed              
=====> app-name checks information
       Checks disabled list:          none                     
       Checks skipped list:           none                     
=====> app-name cron information
       Cron task count:               1
=====> app-name docker options information
       Docker options build:          --link dokku.postgres.app-name:dokku-postgres-app-name --link dokku.redis.app-name:dokku-redis-app-name 
       Docker options deploy:         --link dokku.postgres.app-name:dokku-postgres-app-name --link dokku.redis.app-name:dokku-redis-app-name --restart=on-failure:10 
       Docker options run:            --link dokku.postgres.app-name:dokku-postgres-app-name --link dokku.redis.app-name:dokku-redis-app-name 
=====> app-name domains information
       Domains app enabled:           true                     
       Domains app vhosts:            primestoragegroup.app www.primestoragegroup.app
       Domains global enabled:        false                    
       Domains global vhosts:                                  
=====> app-name git information
       Git deploy branch:             master                   
       Git global deploy branch:      master                   
       Git keep git dir:              false                    
       Git rev env var:               GIT_REV                  
       Git sha:                       9ded4d7                  
       Git last updated at:           1626793726               
=====> app-name logs information
       Logs computed max size:        10m
       Logs global max size:          10m
       Logs global vector sink:       
       Logs max size:                 
       Logs vector sink:              
=====> app-name network information
       Network attach post create:    
       Network attach post deploy:    
       Network bind all interfaces:   false
       Network web listeners:         172.17.0.6:5000 172.17.0.7:5000
=====> app-name nginx information
       Nginx access log format:                                
       Nginx access log path:         /var/log/nginx/app-name-access.log
       Nginx bind address ipv4:                                
       Nginx bind address ipv6:       ::                       
       Nginx client max body size:    50m                      
       Nginx disable custom config:   false                    
       Nginx error log path:          /var/log/nginx/app-name-error.log
       Nginx global hsts:             true                     
       Nginx computed hsts:           true                     
       Nginx hsts:                                             
       Nginx hsts include subdomains: true                     
       Nginx hsts max age:            15724800                 
       Nginx hsts preload:            false                    
       Nginx proxy buffer size:       4096                     
       Nginx proxy buffering:         on                       
       Nginx proxy buffers:           8 4096                   
       Nginx proxy busy buffers size: 8192                     
       Nginx proxy read timeout:      60s                      
       Nginx last visited at:         1626876316               
       Nginx x forwarded for value:   $remote_addr             
       Nginx x forwarded port value:  $server_port             
       Nginx x forwarded proto value: $scheme                  
=====> app-name proxy information
       Proxy enabled:                 true
       Proxy port map:                http:80:5000 https:443:5000
       Proxy type:                    nginx
=====> app-name ps information
       Deployed:                      true
       Processes:                     4
       Ps can scale:                  true
       Ps restart policy:             on-failure:10
       Restore:                       true
       Running:                       true
       Status cron 1:                 running (CID: d168cc1beb0)
       Status web 1:                  running (CID: 3709e933ded)
       Status web 2:                  running (CID: fb7338aacb6)
       Status worker 1:               running (CID: 2d8e09ab610)
=====> app-name resource information
=====> app-name scheduler-docker-local information
       Scheduler docker local disable chown:                          
=====> app-name storage information
       Storage build mounts:                                   
       Storage deploy mounts:                                  
       Storage run mounts:  

How (deb/make/rpm) and where (AWS, VirtualBox, physical, etc.) was Dokku installed?

Digital ocean droplet (Ubuntu 20.04)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions