Creating a cronjob through script

Jack Pettersson

Is there any way to create a cronjob in an automated way (script)?

The only way i know how to create a cronjob is through contab -e which creates a temporary conf file that is, once modified and exited, merged with the actual conf file in /var/spool/cron/crontabs (this file can't be modified directly).

In particular what i'm trying to do is package a script that needs to be run every minute. When the user installs the package, the cronjob needs to be added and there in lies my problem.

So: I need a script to create a script that runs my script, not that confusing right? :P

Barmar

You can use

crontab filename

to install filename as the user's crontab. So your script can do something like:

crontab -l > crontab.txt # Get current crontab
echo "0 12 * * * /path/to/script" >>crontab.txt #Add a new entry
crontab crontab.txt # install new crontab

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Creating a shortcut or a script in Ubuntu

분류에서Dev

Creating table with python script

분류에서Dev

Initialising/Creating Objects through a constructor

분류에서Dev

Why does my cronjob not execute my shell-script?

분류에서Dev

script in cronjob doesn't work with: "Could not open input file"

분류에서Dev

Creating a very simple upstart script

분류에서Dev

Creating an expression with equal to in shell script

분류에서Dev

Error while creating Scrapy project through startproject

분류에서Dev

Bash script fault creating mdadm array

분류에서Dev

Creating executable file with password included in a script

분류에서Dev

Stopping SQL from creating databases if there was an error on script

분류에서Dev

Run the same script on several servers through SSH

분류에서Dev

How to close epiphany through a script with cron?

분류에서Dev

Can we install a package through a shell script?

분류에서Dev

Running a script when users connect through ssh

분류에서Dev

su another user through ssh with a local script

분류에서Dev

Rails 4 - error creating associations through Fabricator in Rspec tests

분류에서Dev

Creating multiple has_many :through records with form_for

분류에서Dev

Creating a table using google app script from a query

분류에서Dev

Creating a bash script to ping and traceroute multiple websites (OSX)

분류에서Dev

Shell Script to Recursively Loop Through Directory and print location of important files

분류에서Dev

sed command works in terminal but not through bash_aliases or a bash script

분류에서Dev

Setting system wide proxy through bash script (Temporarily)

분류에서Dev

Calling and executing vb script by opening command prompt through Batch file

분류에서Dev

tweet button script not functioning when loaded in through ajax

분류에서Dev

Launching a script when someone opens a file through the gui

분류에서Dev

Go through every subfolder, check for a folder and run script

분류에서Dev

Setting system wide proxy through bash script (Temporarily)

분류에서Dev

What is the best way to go through your script once more?

Related 관련 기사

  1. 1

    Creating a shortcut or a script in Ubuntu

  2. 2

    Creating table with python script

  3. 3

    Initialising/Creating Objects through a constructor

  4. 4

    Why does my cronjob not execute my shell-script?

  5. 5

    script in cronjob doesn't work with: "Could not open input file"

  6. 6

    Creating a very simple upstart script

  7. 7

    Creating an expression with equal to in shell script

  8. 8

    Error while creating Scrapy project through startproject

  9. 9

    Bash script fault creating mdadm array

  10. 10

    Creating executable file with password included in a script

  11. 11

    Stopping SQL from creating databases if there was an error on script

  12. 12

    Run the same script on several servers through SSH

  13. 13

    How to close epiphany through a script with cron?

  14. 14

    Can we install a package through a shell script?

  15. 15

    Running a script when users connect through ssh

  16. 16

    su another user through ssh with a local script

  17. 17

    Rails 4 - error creating associations through Fabricator in Rspec tests

  18. 18

    Creating multiple has_many :through records with form_for

  19. 19

    Creating a table using google app script from a query

  20. 20

    Creating a bash script to ping and traceroute multiple websites (OSX)

  21. 21

    Shell Script to Recursively Loop Through Directory and print location of important files

  22. 22

    sed command works in terminal but not through bash_aliases or a bash script

  23. 23

    Setting system wide proxy through bash script (Temporarily)

  24. 24

    Calling and executing vb script by opening command prompt through Batch file

  25. 25

    tweet button script not functioning when loaded in through ajax

  26. 26

    Launching a script when someone opens a file through the gui

  27. 27

    Go through every subfolder, check for a folder and run script

  28. 28

    Setting system wide proxy through bash script (Temporarily)

  29. 29

    What is the best way to go through your script once more?

뜨겁다태그

보관