0

I'm really new on Linux and have no any previous experience on it. And I opened this account to ask this question.

I need to install a cron job

I've followed the short guide here. Well, I think it has been installed successfully. Because, when I type crontab -l, I see it in the result that Putty display. I'm using Putty by the way.


Problem (I'm not sure if this is problem, but seems to be):

I've asked another developer/college to login the server, using Putty, with his own credentials. Means another user. Then I asked type crontab -l. And the result is:

no crontab for username.

So, I guess that cron job is only installed for me.

Question(s):

How can I install it system wide? What I mean is, how can I install it for everyone? If I install if for everyone, does it run as much as number of users when time comes? For example, if there are 3 users in the system, and I install cron job system wide, does it run 3 times (for every user) when time comes to run the scheduled job? Or having the cron job only for a specific username is enough to make the operation? If "no", and if I need to install it system wide, then how to do that, in what step of this guide I need do something different?


Little information about what cron job does. There is a database in the system/server, and the cron job is supposed to update the database from another remote database, on the first date of every month, at 8pm. I've used .sh to install the cron job, by the way.

Thanks everyone for trying help me.

  • I don't know what user has what subset. Honestly. I'm really new to this stuff. All I know is, there is database, and .sh files is designed to manipulate that database, and I need to run that .sh every month. :( – Zafar Aug 20 '14 at 23:56
  • You question is part of my original question. Do I really need to run that for every user? Or having the cron job for my account is enough to make the operation...? – Zafar Aug 21 '14 at 0:00
3

Each user has their own scheduled tasks. If you go and pick your kid from school at 4pm every day, your neighbor doesn't also go and pick your kid at 4pm.

Cron jobs can be registered by each user (in which case they run with that user's privileges) or at the system level (in which case they run as a user chosen by the system administrator). Each scheduled job runs once at each scheduled time.

There's no feature to set up the jobs running the same command for multiple users, other than replicating the job entry. It's not a good idea to schedule many jobs at the same time, because they'll use the same resources.

I'm puzzled as to why you want multiple users to run the same job. Do you have one database, or do you and your colleague each have your own database? If you have a single database, then it only needs to be processed once, you only need one job. If you want both you and your colleague to have access to the output of the job, then generate the output once, and make it readable by both of you. If there are two databases, then each of you should run similar jobs, with the address of the database and the location of the output file adjusted for each job.

  • There is only one database. Only one. Every user has access to that database. Me, he, she. So, that means, I do not need any further action with it... right? I've installed cron job under my username already. – Zafar Aug 21 '14 at 0:05
  • @Zafarbek If there's only one kid, you don't need all of you to pick him up from school. – Gilles Aug 21 '14 at 0:16
  • Thanks for a great answer, and a great kids example. I loved it. – Zafar Aug 21 '14 at 0:17
0

You can put files in your /etc/cron.d as root (or if you are have sudo). You could do something like this ...

# cat > /etc/cron.d/mycronjob <<EOT
* * * * * /bin/logger "Hello from cron"
EOT

... then you can watch your cron job write the system log like so ...

# tail -f /var/log/messages

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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