Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 904537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:04:06+00:00 2026-05-15T16:04:06+00:00

Is there a way to allow hook_cron to run with administrator privileges — e.g

  • 0

Is there a way to allow hook_cron to run with administrator privileges — e.g a sort of sudo hook_cron() as it were?

This question is a follow up to my earlier question trying to diagnose why hook_cron() functions invoked by /drupal/cron.php run differently that the same functions invoked by /admin/reports/status/run-cron.

My particular function (call it foo_cron()) updates user profiles as part of its nightly duties. But, /drupal/cron.php apparently runs as an anonymous user. Anonymous users cannot modify user profile fields in this site, for obvious reasons, so this part of the script fails.

I know I can work around this by modifying profile_fields directly using SQL, but that feels like an ugly hack, and could be tough to maintain if I start doing this in multiple modules.

Is the a way, within the existing Drupal functions and framework, to make certain foo_cron() jobs run with privs that we normally only give administrators, such as updating profiles?

This particular site is running Drupal 6.1.3.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T16:04:07+00:00Added an answer on May 15, 2026 at 4:04 pm

    From drupal cron manual page:
    Running cron as an authenticated user

    #!/bin/sh
    # Reference http://drupal.org/node/479948#comment-1673488 by pearlbear
    
    SITE=https://dev.example.com/
    USERNAME=user.name
    PASS=ChangeMe!!12
    
    COOKIES=/tmp/cron-cookies.txt
    WGETPARAMS="--quiet -O /dev/null --no-check-certificate --save-cookies $COOKIES --keep-session-cookies --load-cookies $COOKIES"
    # if you run drupal in a default language different than English you need to modify this
    LOGIN="Log%20in"
    
    wget $WGETPARAMS "${SITE}user"
    wget $WGETPARAMS --post-data="name=$USERNAME&pass=$PASS&op=$LOGIN&form_id=user_login" "${SITE}user"
    wget $WGETPARAMS " ${SITE}cron.php"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a simple question. Is there a way to allow users to enter
Is there any way to allow non-Administrator users to install, upgrade or uninstall an
Is there a way to allow a user, after he has created a vector
Is there a way to allow an HTML file to open an application on
Using SQL Server 2008, is there a way to allow inserts to a table
Is there a way (hacky will do) to allow a user to go back
Is there a way to allow a custom wx.Dialog to be resized in the
Is there a way to allow people to handwrite on the tablet with a
Is there a way to allow users to specify how many slides they want
is there a way to allow umlauts-domains for e-mail addresses in Magento? when entering

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.