user2834795
user2834795

Reputation: 4503

how to set up cron in ubuntu from root?

I am getting stuck to set cron in ubuntu server from root.

When i try using:- sudo crontab -e it gives me error "no crontab for root - using an empty one 888"

Please help me out.I need to set up cron for every minute.

Upvotes: 0

Views: 7463

Answers (2)

s-hunter
s-hunter

Reputation: 25816

Assume you have a hello.sh in /home/username/hello.sh with the code below

#!/bin/bash
echo "Hello World!!!"

Create a file /etc/cron.d/hellocron and put the below line in it

* * * * * root /home/username/hello.sh

The cron will run /home/username/hello.sh every minute, in this example, it will print the string "Hello World!!!" every minute.

Upvotes: 1

TeTeT
TeTeT

Reputation: 2094

Check out the directories in /etc/cron* to add system wide cron jobs.

Upvotes: 0

Related Questions