We know the crontab
command is used for scheduled tasks in Linux.
I want to write a Python script. Its function is to receive some data (these data are related to crontab setting) and execute a 'crontab' command in order to reset the content of the user's crontab file.
I know how to execute external Linux commands in Python. But when you execute the crontab
command (e.g. crontab -u xxx -e
), you need to interact with an editor to modify the user's crontab file. (Suppose I don't know where the file is. For new users, crontab
will generate a new file anyway. And I don't execute the command as the root
user).
So the question is, how can I just execute crontab
in Python? Is there any way to avoid interacting with an editor to modify the user's crontab file in Python?
My OS is ubuntu 14.01.