GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - linbc/crontab.lua: lua crontab

BranchesTags
Open more actions menu

Latest commit

 

History

11 Commits
11 Commits

Folders and files

NameName
Last commit message
Last commit date
LICENSE
LICENSE
 
 
README.md
README.md
 
 
crontab.lua
crontab.lua
 
 

Repository files navigation

crontab.lua

lua crontab

参考资料:

  • http://www.cise.ufl.edu/~cop4600/cgi-bin/lxr/http/source.cgi/commands/simple/cron.c
  • https://github.com/kikito/cron.lua

中文使用说明

  • http://www.cnblogs.com/linbc/p/4299065.html

--传说中的测试代码

function RunTests()

-- the following calls are equivalent
function printMessage(a )
  print('Hello',a)
end

local cron = crontab.new()

local c1 = cron:after( 5, printMessage)
local c2 = cron:after( 5, print, {'Hello'})

c1:update(2) -- will print nothing, the action is not done yet
c1:update(5) -- will print 'Hello' once

c1:reset() -- reset the counter to 0

-- prints 'hey' 5 times and then prints 'hello'
while not c1:update(1) do
  print('hey')
end

-- Create a periodical clock:
local c3 = cron:every( 10, printMessage)

c3:update(5) -- nothing (total time: 5)
c3:update(4) -- nothing (total time: 9)
c3:update(12) -- prints 'Hello' twice (total time is now 21)

-------------------------------------
c1.deleted = true
c2.deleted = true
c3.deleted = true

------------------------------
--测试一下match
print('----------------------------------')
assert(match('*',14) == true)
assert(match('12-15',14) == true)
assert(match('18-21',14) == false)
assert(match('18,21',14) == false)
assert(match('18,21,14',14) == true)

--加一个定时器1分钟后执行
cron:update(1000)

--加入一个定时器每分钟执行
cron:addCron('每秒执行', '* * * * *', print, {'.......... cron'})

cron:update((60-os.time()%60)*1000)
cron:update(30*1000)
cron:update(31*1000)
cron:update(1)
cron:update(60*1000)		--打印两次

end

About

lua crontab

Resources

Readme
MIT license
Activity

Stars

35 stars

Watchers

1 watching

Forks

3 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.