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
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] 삭제
몇 마디 만하겠습니다