0

I'm trying to work with crontab.

In crontab -e:

*/10 * * * * rm home/user/Desktop/myFile 

trying to delete myFile at every 10th minute.

I enabled Crontab using:

/etc/init.d/cron start

and then: sudo rcconf to ensure that the service remains after rebooting but it doesn't work!

user@ubuntu:~$ sudo update-rc.d cron defaults
user@ubuntu:~$ /etc/init.d/cron start
[ ok ] Starting cron (via systemctl): cron.service.

closed as off-topic by Kusalananda, Jeff Schaller, slm Jul 3 '18 at 3:30

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Kusalananda, Jeff Schaller, slm
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    Cron should already be running by default. It looks as if you are missing an initial slash in the pathname to the file you're trying to delete. – Kusalananda Jul 2 '18 at 12:30
2
*/10 * * * * rm home/user/Desktop/myFile

You forgot to add a slash at the beginning to make it an absolute path. As it is, it probably won't work.

It should be:

*/10 * * * * rm /home/user/Desktop/myFile
  • Alternatively rm "$HOME/Desktop/myfile" or rm Desktop/myfile (assuming cron uses the home directory as working directory) if it's the same user that runs the cronjob. – Kusalananda Jul 2 '18 at 13:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.