Code Monkey home page Code Monkey logo

cronhw's Introduction

Note: this code was written as a school homework. It is not going to be maintained and is not meant to be used in production. The only reason for publishing this is that its one of requirements. (the commit history is missing since I use an implicit versioning system on projects I don't intend to publish)

general description

Cron daemon is used for task scheduling. The daemon wakes up every minute, goes through all records and for every one decides whether it is to be ran. If so, the supplemented command is executed in a separate shell and its output then outputted into the daemon's output.

process execution

Command is executed as a separate process in /bin/sh. All processes get executed paralelly, thus order is not defined. When process finishes, it is checked and its output written to standard output. This is done every minute.

cron format

Tasks are accepted in the following format: , where the first 5 fields are comma separated lists of numbers and ranges. Note that this format uses spaces as field separators, thus spaces are forbidden inside of a field (e.g. '1, 2' as is invalid).

variable expansion

Standard shell-like variables can be used in the file. Line in format of = can be used to set the variable varname to the value 'value'. Later the variable may be used as $varname. Double dollar is resolved to a single dollar. Variables are not evaluated recursively.

There are four variables set by default: LOGNAME, HOME, SHELL and PATH. LOGNAME and HOME are set from env, SHELL is set to /bin/sh and path is set to /bin:/usr/bin by default. All of these values may be overriden.

compilation

To compile this project, use the make command. The output file is mycrond.

tests

Some tests are provided with expected output in folders test1, test2, test3.

The binary was checked for memory leaks by valgrind.

usage

following options are available: -f (for now obligatory) -d daemonize -s silent -o once (for memtest purposes)

Example:

cronfile: path=/media/data 30 8-20 * * 2 backup $path

command: mycrond -f cronfile

This executes 'backup /media/data' 12 times on every wensday (at 8:30,9:30 ...)

cronhw's People

Contributors

kareltucek avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.