Closed OdilKurbanov closed 1 year ago
Does user myuser has appropriate rights to see and modify cronjobs of user www-data?
Or maybe line https://github.com/bnosac/cronR/blob/master/R/cron_add.R#L253 should add flag -u
Does user myuser has appropriate rights to see and modify cronjobs of user www-data?
Thank you for your prompt reply. Yes, myuser
is a member of the www-data group.
You are right, passing the user seems not implemented for adding and removing. It only works for the user which you use to call the function which is the reason why you saw it as user 'myuser'. The usage of the -u flag
in all the system calls needs to pass the user. This needs to be changed in cron_add
, cron_rm
and cron_clear
Thank you for further looking into this. I tested from my www-data user too. I'm able to add a cron job but user=myuser
is not changing the owner, cron is added for www-data user.
Yes, the package is changing the cron job currently only for the current logged in user
It's clear now. Thank you for this cool package. Would be really great if you find time to implement adding/removing cron jobs on behalf of other users of the system.
I've made the changes in commit https://github.com/bnosac/cronR/commit/58b0616369dea9b35a793c0ff36344dd351db829 to honour the use of argument user
in cron_add
and cron_rm
.
Can you install the development version with remotes::install_github("bnosac/cronR")
and let me know how it goes.
I installed the dev version and run cron_add command
cron_add(command = cmd, frequency = 'minutely', id = 'test1', user = 'www-data')
and I was asked before adding this cron
Are you sure you want to add the specified cron job: '/usr/lib/R/bin/Rscript '/home/myuser/testfolder/crontesting.R' >> '/home/myuser/testfolder/crontesting.log' 2>&1'? [y/n]
then I checked number of cron jobs by users:
cron_njobs(user='www-data')
# No cron jobs available for user 'www-data'.
cron_njobs(user='myuser')
#There are a total of 1 cronR cron jobs and 0 other cron jobs currently running.
Seems cronR version 0.6.4 is not respecting user='www-data' yet.
Thank you for your effort.
Can't reproduce this behaviour. I get the following when ran as another user then www-data. Note the must be privileged to use -u
.
> myscript <- system.file("extdata", "helloworld.R", package = "cronR")
>
> f <- system.file(package = "cronR", "extdata", "helloworld.R")
> cmd <- cron_rscript(f)
> cron_add(command = cmd, frequency = 'minutely', id = 'abc', description = 'My process 1', user = "www-data")
Are you sure you want to add the specified cron job: '/usr/lib/R/bin/Rscript '/home/jwijffels/R/x86_64-pc-linux-gnu-library/3.6/cronR/extdata/helloworld.R' >> '/home/jwijffels/R/x86_64-pc-linux-gnu-library/3.6/cronR/extdata/helloworld.log' 2>&1'? [y/n]:
1: y
Adding cronjob:
---------------
## cronR job
## id: abc
## tags:
## desc: My process 1
0-59 * * * * /usr/lib/R/bin/Rscript '/home/jwijffels/R/x86_64-pc-linux-gnu-library/3.6/cronR/extdata/helloworld.R' >> '/home/jwijffels/R/x86_64-pc-linux-gnu-library/3.6/cronR/extdata/helloworld.log' 2>&1
must be privileged to use -u
As user root If I run this as root. The cronjob is put for user www-data
> library(cronR)
> myscript <- system.file("extdata", "helloworld.R", package = "cronR")
>
> f <- system.file(package = "cronR", "extdata", "helloworld.R")
> cmd <- cron_rscript(f)
> cron_add(command = cmd, frequency = 'minutely', id = 'abc', description = 'My process 1', user = "www-data")
Are you sure you want to add the specified cron job: '/usr/lib/R/bin/Rscript '/usr/local/lib/R/site-library/cronR/extdata/helloworld.R' >> '/usr/local/lib/R/site-library/cronR/extdata/helloworld.log' 2>&1'? [y/n]: 1: y
Adding cronjob:
---------------
## cronR job
## id: abc
## tags:
## desc: My process 1
0-59 * * * * /usr/lib/R/bin/Rscript '/usr/local/lib/R/site-library/cronR/extdata/helloworld.R' >> '/usr/local/lib/R/site-library/cronR/extdata/helloworld.log' 2>&1
> cron_ls(user="www-data")
## cronR job
## id: abc
## tags:
## desc: My process 1
0-59 * * * * /usr/lib/R/bin/Rscript '/usr/local/lib/R/site-library/cronR/extdata/helloworld.R' >> '/usr/local/lib/R/site-library/cronR/extdata/helloworld.log' 2>&1
> cron_njobs(user = "www-data")
There are a total of 1 cronR cron jobs and 0 other cron jobs currently running.
> cron_clear(user = "www-data")
Are you sure you want to clear all cron jobs for 'www-data'? [y/n]: 1: y
Crontab cleared.
> cron_njobs(user = "www-data")
No cron jobs available for user 'www-data'.
Let me double-check, I will get back to you with the result. Thanks
I'm checking with user in sudo group but not root, and getting must be privileged to use -u
warning.
Looking how to grant using -u
. Will update on progress.
Hi there, Thanks for a great package. I'm currently testing cronR. I'm trying to add a new cron on behalf of 'www-data' user from myuser account in RStudio
But cron is added on behalf of myuser:
And not for www-data user
What could be the problem? Thank you!